Save a list to a .txt file and keep them
Question:
I found a way to print the list to a txt file, and it worked for me. Except for one detail,
with open("data.txt", "w") as output:
output.write(str(list))
When I make a different data entry, new data replaces the old data I entered, I want it not to delete the old data and continue recording new data.
Answers:
using "w"
in the open function will rewrite the complete file so use "a"
in the open function which will append the file and you will not lose the original text in the file
I found a way to print the list to a txt file, and it worked for me. Except for one detail,
with open("data.txt", "w") as output:
output.write(str(list))
When I make a different data entry, new data replaces the old data I entered, I want it not to delete the old data and continue recording new data.
using "w"
in the open function will rewrite the complete file so use "a"
in the open function which will append the file and you will not lose the original text in the file