- 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!")

18th Jul 2021, 4:12 PM
Zach Z
8 odpowiedzi
+ 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!
18th Jul 2021, 7:14 PM
Lothar
Lothar - avatar
18th Jul 2021, 5:11 PM
Simba
Simba - avatar
+ 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")
21st Jul 2021, 9:02 PM
Zach Z
+ 1
def withdraw(amount): print(str(amount) + " withdrawn!") n=input() try: int(n) withdraw(n) except: print("Please enter a number")
30th Mar 2023, 10:23 PM
المهندس أحمد
المهندس أحمد - avatar
0
I tried not working
12th Sep 2023, 8:13 AM
Amrit Kumar Ojha
Amrit  Kumar Ojha - avatar
0
Please help me
12th Sep 2023, 8:13 AM
Amrit Kumar Ojha
Amrit  Kumar Ojha - avatar
0
Am stuck
12th Sep 2023, 8:13 AM
Amrit Kumar Ojha
Amrit  Kumar Ojha - avatar
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")
5th Dec 2023, 10:37 PM
Ahmad Yusuf
Ahmad Yusuf - avatar