I'm trying to add saves to my code. The loading works, and I am able to write the strings into the text file, but I can't figure out how to write an integer (number) into the txt file.
I've tried to define the integers as strings but none have worked.
(Variable names are in Norwegian.)
def save():
with open("a.txt") as f:
f.write(int(penger))
f.write(int(vognplass_list[0]))
f.write(int(vognplass_list[1]))
f.write(int(vognplass_list[2]))
f.write(str(vognplasser[0]))
f.write(str(vognplasser[1]))
f.write(str(vognplasser[2]))
The error says:
TypeError: write() argument must be str, not int