while 1:
text_file = open("write_it.txt", "w")
word = input("Please add to a text file: ")
What else do I need to add to make my code run properly?
while 1:
text_file = open("write_it.txt", "w")
word = input("Please add to a text file: ")
What else do I need to add to make my code run properly?
Not sure, but that open statement inside of the while couldn't be affecting its behaviour? Have you tried just moving it out of while loop?
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()