How to call a certain function inside an if statement in python? -
i relatively new python, in foundation year learned bbc basic pretty basic , acquired many bad habits there. learned python aid of codecademy, however, how can call function inside if statement? in first if statement called function mainmenu(menu), however, not displaying function contents. why?
(by way trying atm machine practice of things learned , consolidate
print "hello ! welcome jd's bank" print print "insert bank card , press key procede" print raw_input() passcode = 1111 attempts = 0 while passcode == 1111: passcodeinsertion= raw_input("please insert 4-digit code: ") print"" if passcodeinsertion == str(passcode): print "this working" #testing----- print "" mainmenu(menu) elif attempts < 2: print "sorry ! wrong passcode" attempts += 1 print "------------------------------------------------" print "" print"try again !! " + str(attempts) + " attempt" print print "------------------------------------------------" print else: print"" print "your card unfortunately blocked" exit() def mainmenu(menu): print "------------------------------------------------" print "select 1 of options" print "1. check balance" print "2. withdraw money" print "3. deposit money " print "0. exit " print "------------------------------------------------"
print "hello ! welcome jd's bank" print print "insert bank card , press key procede" print raw_input() def mainmenu(): print "------------------------------------------------" print "select 1 of options" print "1. check balance" print "2. withdraw money" print "3. deposit money " print "0. exit " print "------------------------------------------------" passcode = 1111 attempts = 0 while passcode == 1111: passcodeinsertion= raw_input("please insert 4-digit code: ") print"" if passcodeinsertion == str(passcode): print "this working" #testing----- print "" mainmenu() elif attempts < 2: print "sorry ! wrong passcode" attempts += 1 print "------------------------------------------------" print "" print"try again !! " + str(attempts) + " attempt" print print "------------------------------------------------" print else: print"" print "your card unfortunately blocked" exit() try above. moved mainmenu top , don't need parameters.
Comments
Post a Comment