- 2
Intermediate Python - 29.2 Practice help- âCash Outâ
Please help, thanks! An ATM machine takes the amount to be withdrawn as input and calls the corresponding withdrawal method. In case the input is not a number, the machine should output "Please enter a number". Use exception handling to take a number as input, call the withdraw() method with the input as its argument, and output "Please enter a number", in case the input is not a number. def withdraw(amount): print(str(amount) + " withdrawn!")
8 Respostas
+ 6
Zach Z ,
the code you are showing here seems to be incomplete. please make sure that you have read the task description carefully.
it would be very helpful if you can show us your complete code:
=> please put your code in playground and link it here
thanks!
+ 4
Where is your try-except statements?
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2441/
+ 1
Figured it out, thanks!
def withdraw(amount):
print(str(amount) + " withdrawn!")
try:
num=int(input())
withdraw(num)
except (ValueError, TypeError):
print("Please enter a number")
+ 1
def withdraw(amount):
print(str(amount) + " withdrawn!")
n=input()
try:
int(n)
withdraw(n)
except:
print("Please enter a number")
0
I tried not working
0
Please help me
0
Am stuck
0
def withdraw(amount):
print(str(amount) + " withdrawn!")
try:
num = int(input("")) # Convert input to a floating-point number
withdraw(num)
except ValueError: #The Error is the value and not the TypeError
print("Please enter a number")