I'm new to python so this is most likely basic knowledge, but how do I read a number from a text file and use it as a variable? I'm trying to make a game where it counts your points and saves it to a plain text file, and when you first run the game it checks for that file and reads the points from your last session. I tried this but it didnt work:
for saving:
def save():
with open('gameSave.txt', 'w') as f:
for points in points:
f.write('%d' % points)
for loading:
with open("gameSave.txt", "r", encoding="utf-8") as g:
points = g.readlines()
can anyone help? The points just need to be loaded and save as an integer but i can't figure out how.