while 1: text_file = open("write_it.txt", "w") word = input("Please add to a text file: ")
¿Qué más necesito agregar para que mi código se ejecute correctamente?
Esto debería funcionar:
text_file = open("write_it.txt", "w") while 1: word = input("Please add to a text file: ") if not word: break text_file.write(word) text_file.close()
¿No está seguro, pero esa statement abierta dentro de un tiempo no podría afectar su comportamiento? ¿Has intentado simplemente moverlo fuera de tiempo loop?