Hi ,
I am trying to solve beginner level question ,ATM , I have included ‘input’ in my code to fetch user input,it works fine in my local system ,but when I tried to upload the code in codeChef ,it throws runtime error in CodeChef, I tried running the code in online compiler ,it says , its throwing error because it is waiting for user input .
Below is the code snippet :
def ATM() :
while True:
try:
withdrawl = int(input("Please enter any amount(withdrawl) which is multiple of 5 between 0 to 2000 "))
except ValueError:
print("Please enter a number/integer as withdrawl amount")
continue
if 0< withdrawl <= 2000 :
break
else :
continue
while True:
try:
balance = float(input("Please enter any amount(balance) between 0 to 2000 "))
except ValueError:
print("Please enter a number")
continue
if 0<= balance <= 2000 :
break
else :
continue
if withdrawl < balance :
if withdrawl%5 ==0 :
remaining = balance-withdrawl
print('%.2f'%remaining)
else :
print(" Incorrect Withdrawal Amount (not multiple of 5)")
else:
print("insufficient funds")
ATM()
Below is the code I tried using :
def ATM() :
while True:
try:
withdrawl = int(input())
except ValueError:
continue
if 0< withdrawl <= 2000 :
break
else :
continue
while True:
try:
balance = float(input())
except ValueError:
continue
if 0<= balance <= 2000 :
break
else :
continue
if withdrawl < balance :
if withdrawl%5 ==0 :
remaining = balance-withdrawl
print('%.2f'%remaining)
else :
print(" Incorrect Withdrawal Amount (not multiple of 5)")
else:
print("insufficient funds")
ATM()
But still got run time error