[Solved] How can I write to the textfile with “while”?


This should work:

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()

solved How can I write to the textfile with “while”?