0

Can anyone see what's wrong with this code?

#Am I being silly or should this code be working just fine? def fund(): money = input("Please enter how much money you have: ") return money def check_money(money): if money == int(money): return money else: return check_money(fund()) check_money(fund()) """ This code is intended to keep asking how much money you have, until you give it a valid integer. Then it should return money """

25th Sep 2018, 5:06 PM
Jacob
2 Answers
+ 6
if money == int(money) is not good. if money.isnumeric().... wont work on SL btw
25th Sep 2018, 5:32 PM
Oma Falk
Oma Falk - avatar
0
Codeit thanks for answering.. I ended up replacing the whole thing with an exception: def fund(): fund = raw_input("Please enter how much money you have: ") try: return int(funds) except InputError: print("You must enter a valid amount...") return fund() this seems to work fine
2nd Nov 2018, 8:54 PM
Jacob