I'm learning Python and have made this start of a ATM program, I'm very new to this so please be gentle..
Is there a better way to rewrite this?
CHECKING_BALANCE = 4000
SAVINGS_BALANCE = 1000
def welcome_screen():
print """
Welcome to the Bank of Bam!
To continue please follow the instructions:
Press 1 for Checking Account
Press 2 for Savings Account
Press 3 for Balance Inquiries
Press 4 to return card and exit
"""
choice = int(raw_input("> "))
if choice == 1:
checking_account()
elif choice == 2:
savings_account()
elif choice == 3:
balance_inquiries()
else:
print "Exiting..."
def checking_account():
print "You have $%i available" % (CHECKING_BALANCE)
print """
What would you like to do:
[W]ithdrawl
[D]eposit
[T]ransfer funds
"""
choice = raw_input("> ")
if choice == "W":
withdraw_funds()
elif choice == "D":
deposit_funds()
elif choice == "T":
transfer_funds
else:
print "Invalid input.."
def savings_account():
print "You have $%i available" % (SAVINGS_BALANCE)
print """
[W]ithdrawl
[D]eposit
[T]ransfer
"""
choice = raw_input("> ")
if choice == "W":
withdraw_funds()
elif choice == "D":
deposit_funds()
elif choice == "T":
transfer_funds()
else:
print "Invalid input.."
welcome_screen()
Example of usage:
Welcome to the Bank of Bam!
To continue please follow the instructions:
Press 1 for Checking Account
Press 2 for Savings Account
Press 3 for Balance Inquiries
Press 4 to return card and exit
> 1
You have $4000 available
What would you like to do:
[W]ithdrawl
[D]eposit
[T]ransfer funds
> Traceback (most recent call last): #<= CRTL - C
File "atm.py", line 58, in <module>
welcome_screen()
C:\Users\Justin\MyScripts>python atm.py
Welcome to the Bank of Bam!
To continue please follow the instructions:
Press 1 for Checking Account
Press 2 for Savings Account
Press 3 for Balance Inquiries
Press 4 to return card and exit
> 2
You have $1000 available
[W]ithdrawl
[D]eposit
[T]ransfer
> Traceback (most recent call last): #<= CTRL - C
File "atm.py", line 58, in <module>
welcome_screen()
File "atm.py", line 17, in welcome_screen
savings_account()
File "atm.py", line 48, in savings_account
choice = raw_input("> ")
EOFError