I am trying to build an ATM code , but I have another piece of code that is again proving troublesome. Here is the error:
How Much Funds Do You Wish To Input Into Your Account? : £1565
Not A Vaild Amount
I am trying to make any integer be an acceptable answer, here is the code I created to check the answer:
def inputFunds(self):
funds_input =(input("How Much Funds Do You Wish To Input Into Your Account? : £"))
num_check = isinstance(funds_input, float)
if num_check == "True" :
self.balance = self.balance + funds_input
print("Input Complete. Your New Balance is £" + self.balance)
else:
print("Not A Vaild Amount")
tryagain =(input("Do You Wish To Try Again?"))
if tryagain in ("Y", "y", "Ye", "ye", "Yes", "yes"):
print(atm.inputFunds())
else:
back_menu =(input("Do You Wish To Go Back To The Menu? "))
if back_menu in ("Y", "y", "Ye", "ye", "Yes", "yes"):
print(atm.Menu())
else:
print(atm.End())
This is the last thing I need to make my code run smoothly. Many Thanks.
EDIT
Having tried both the other answer that has been linked , and also the advice given below. My code still gives an syntax error to the 'except' statement. Here is my code now:
def inputFunds(self):
try:
funds_input = int(input("How Much Funds Do You Wish To Input Into Your Account? : £"))
self.balance = self.balance + funds_input
print("Your New Balance Is £" + str(self.balance)
except ValueError:
print("Not A Valid Amount")
tryagain = input("Do You Wish To Try Again? ")
if tryagain in ("Y", "y", "Ye", "ye", "Yes", "yes"):
print(atm.inputFunds())
else:
back_menu = input("Do You Wish To Go Back To The Menu? ")
if back_menu in ("Y", "y", "Ye", "ye", "Yes", "yes"):
print(atm.Menu())
else:
print(atm.End()