Created
October 8, 2013 21:42
-
-
Save rorhug/6892291 to your computer and use it in GitHub Desktop.
Aidan bank thingy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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