I need to build a gift voucher section of my python cash register software
Here's the code I have so far
elif payment == '3': print "Scan or enter gift card" cardno = raw_input('Card Number: ') try: with open(cardno, '.txt') as f: pass value = f.readline() except IOError as e: print 'Invalid number'
Just to clarify how my code works, when a gift card is created a text file called [card number].txt is created. I need to read the first line of this file, which contains the amount left on the gift card (eg 15.30). I need to check that this number is bigger than a variable called total, if it is take total away from the value of the gift card and over-write the file. If not, display error.
I have no idea where to go after the code I have written!
Edited by fheppell: mis spelt title