Oct-04-2017, 07:11 PM
Hi I am trying to create a fake python bank system. The program needs to be able to deposit, withdraw and check the balance. However when i run the code in python on mac the program seems to only loop the options over and over again
when i run the program and enter a number to select and option it brings me back to the same menu
for example
Welcome to the Python Bank System
Your Transaction Options Are:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1) Deposit Money
2) Withdraw Money
3) Check Balance
4) Quit Python Bank System.pyw
Choose your option: 3
Thank-You for stopping by the bank!
Welcome to the Python Bank System
Your Transaction Options Are:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1) Deposit Money
2) Withdraw Money
3) Check Balance
4) Quit Python Bank System.pyw
Choose your option: 4
Thank-You for stopping by the bank!
Welcome to the Python Bank System
Your Transaction Options Are:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1) Deposit Money
2) Withdraw Money
3) Check Balance
4) Quit Python Bank System.pyw
Choose your option:
when i run the program and enter a number to select and option it brings me back to the same menu
for example
Welcome to the Python Bank System
Your Transaction Options Are:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1) Deposit Money
2) Withdraw Money
3) Check Balance
4) Quit Python Bank System.pyw
Choose your option: 3
Thank-You for stopping by the bank!
Welcome to the Python Bank System
Your Transaction Options Are:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1) Deposit Money
2) Withdraw Money
3) Check Balance
4) Quit Python Bank System.pyw
Choose your option: 4
Thank-You for stopping by the bank!
Welcome to the Python Bank System
Your Transaction Options Are:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1) Deposit Money
2) Withdraw Money
3) Check Balance
4) Quit Python Bank System.pyw
Choose your option:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#THIS PART IS NOT THE CODE ITSELF THESE ARE JUST COMMANDS def menu(): money = int ( 5000 ) money = float (money) #print the options you have print ( "Welcome to the Python Bank System" ) print ( " " ) print ( "Your Transaction Options Are:" ) print ( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ) print ( "1) Deposit Money" ) print ( "2) Withdraw Money" ) print ( "3) Check Balance" ) print ( "4) Quit Python Bank System.pyw" ) print return input ( "Choose your option: " ) #Here is the deposit part.... This is where the user inputs the amount of money #they wish to deposit into their account. def deposit(money): global balance deposit = input ( "How much: $" ) deposit = float (deposit) if deposit < = money: balance = balance + 1 money = money - deposit money = float (money) deposit = deposit * . 1 deposit = float (deposit) balance = deposit + balance balance = float (balance) print ( "depositing balance = %7.2f, money = %7.2f" % (balance, money)) print bank_balance(balance) return balance #This is where the user inputs the amount of money they wish to withdraw from #their account. Currently not programmed in as of yet. def withdrawl(balance, money): print ( "Sorry, but this function is currently under construction!" ) print return #This is an obvious one, this is where you check your balance. def bank_balance(balance): print ( "Balance: $" , balance) return balance # NOW THE PROGRAM REALLY STARTS, AS CODE IS RUN balance = 0 balance = float (balance) money = 5000 money = float (money) loop = 1 choice = 0 while loop = = 1 : choice = menu() if choice = = 1 : deposit = deposit(money) elif choice = = 2 : withdraw = withdrawl(balance, money) elif choice = = 3 : balance = bank_balance(balance) elif choice = = 4 : loop = 0 print ( "Thank-You for stopping by the bank!" ) #END OF THE PROGRAM |