Making A Statistics Text File (Python) -
i'm making program takes name , input in form of numbers , gives them score want score saved in text file , want able multiple times when write file overwrites last stat there anyway change
here function i'm using:
def calculate(): try: = float(enter1.get()) b = float(enter2.get()) c = float(enter3.get()) d = float(enter4.get()) e = float(enter5.get()) f = float(enter6.get()) result =(a+b+(c*2)+(d*2)+e-f)*2.5 n = result w = "score:" label7.config(text=str(result)) myfile = open('stats.txt','w') x = str(enter0.get()) y =("(%s) %s" % (w, n)) myfile.write(x) myfile.write(y) myfile.close() except valueerror: label7.config(text='enter numbers!',fg="white")
maybe change
myfile = open('stats.txt','w')
into
myfile = open('stats.txt','a') # append
Comments
Post a Comment