I need to save some variables to a file and load them in, I save each variable to a new line so i use "\n", however when i have to convert it back to an integer when I read from the file i get an error because \n counts as a string. How do i write variables in a new line and read them as integers too?
x=0
y=0
def save_to_file():
file = open("savefile.txt","a")
file.write('%s\n' % x)
file.write('%s\n' % y)
file.close()
def load_from_file():
file = open("savefile.txt","r")
x=int(file.readline())
y=int(file.readline())
file.close()