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 """
2 Answers
+ 6
if money == int(money) is not good.
if money.isnumeric()....
wont work on SL btw
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