Skip to content

Instantly share code, notes, and snippets.

@rorhug
Created October 8, 2013 21:42
Show Gist options
  • Save rorhug/6892291 to your computer and use it in GitHub Desktop.
Save rorhug/6892291 to your computer and use it in GitHub Desktop.
Aidan bank thingy
def get_current_num():
f = open("statement", "r")
num = int(f.read())
f.close()
return num
def write_new_num(n):
f = open("statement", "w")
stmt_string = str(n)
f.write(stmt_string)
f.close()
current_balance = None
try:
current_balance = get_current_num()
print("you have " + str(current_balance))
except IOError:
current_balance = 0
print 'Oh dear. You don\'t have an account. Creating one now...'
input_difference = int(raw_input("Enter amount to change by:").rstrip())
current_balance += input_difference
write_new_num(current_balance)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment