Dec-05-2017, 06:43 PM
I am new to python and decided to see if I could create an ATM program I called a JTM as a joke but anyway I have it working well I just want to make it so when you want to withdraw an amount that will make your balance < 0 you won't be able to. So as long as balance > 0 you can withdraw otherwise you get a message saying you are unable to withdraw check balance, and then loop back to the beginning.
balance = 0 withdraw = 0 option = 0 deposite = 0 import sys print("Welcome to the JTM") input("Press ENTER to continue") def another(): answer = input("Would you like to make another transaction y/n?: ").lower() if answer == 'y': active = True else: active = False sys.exit("Thank you for using JTM") active = True while active: print("1: Deposite") print("2: Withdraw") print("3: Balance") option = int(input("What would you like to do: ")) if option == 1: deposite = int(input("How much would you like to deposite: ")) print("Your deposited $" +str(deposite)) balance = balance + deposite another() elif option == 2: print("Your total amount avalible for withdrawal is: $" +str(balance)) withdraw = int(input("Withdraw: $")) balance = balance - withdraw another() elif option == 3: print("balance: $" +str(balance)) another() else: sys.exit("Thanks")