HI I want to ask how I can open a file like this one: and add together each line (each time the program runs it could add more lines) amount of lines could change below are six. I want to get a total from these below would be $28.00 The floats would always be .00 I think these are integer amounts I am not sure rite now why the program is putting out $0.00 but never mind that. thanks for any help Code: $0.00 $10.00 $0.00 $10.00 $0.00 $8.00 totals= open("C:\\write_it.txt", "r") totals.read(totalc) Label(aApp,text= "You purchased: $%.2f \n" % totalc, font=('times', 10, 'bold')).grid(row=0,column=0) print('total-c', totalc) totals.close()
also this is how i fed the file Code: totals = open("C:\\write_it.txt", "a") totals.write('$%.2f \n' % totalc) print('This is total-C', totalc) totals.close() print('total',total,'total b',totalb,'total-c',totalc)