I've been successful in being able to write lines to a txt file. My issue is, after running the program the first time, my information, when running it a second time, is deleted from those text files. Naturally, this makes my if statement in end_program() not work. Any ideas on how to permanently save information to a txt file in Python? Here is my code:
def start_program():
state = ""
income = ""
I = ["" + ""]
file = open("activation.txt", "w+")
file.write("1")
file.close()
with open("information.txt", "w+") as file_1:
I = [chk_state_1() + "\n" + chk_income()]
file_1.writelines(I)
def end_program():
with open("activation.txt","r+") as activate:
if not activate.readline(0) == "activated":
activate.write("activated")
start_program()
else:
print("hello")
end_program()
Another odd issue, is when the program is ran it will put an "l" in front of activated in the activation.txt
Please help!!