Python: setting max for bank withdraw -
i'm new python , still trying hang of it. i'm attempting change processing function in following code user can not withdraw more money "bank" has on record, 500. hoping help. enter if statement >500?
#simple bank atm def main(): pin=7777;balance=500;pin=0;success=false pin=getinput(pin) pin,pin,balance,success=processing(pin,pin,balance,success) display(success,balance) #input function def getinput(pin): pin=int(input(“please enter pin:”)) return pin #processing function def processing(pin,pin,balance,success): if pin==pin: success=true amt=float(input(“how withdraw?”)) balance=balance-amt return pin,pin,balance,success else: success=false return pin,pin,balance,success
you can use if
condition this.
if amt <= balance: #can't withdraw on current balance balance -= amt else: print("error. amount exceeds funds on record.")
also, other things aside you're returning same thing inside if
, else
condition , if want return it's redundant have in both. can have after else statement @ same indentation level
Comments
Post a Comment