+ 3

Bank card PIN system

i have tried this code but getting error can anyone help me in python pin = int(input()) try: print("PIN code is created") except ValueError: print("Please enter a number")

6th Feb 2021, 3:57 PM
Dhanu Sri Mulakala
Dhanu Sri Mulakala - avatar
12 Respostas
+ 14
// Your program should get the error when getting the input, because int(input()) is the part where 'ValueError' may occur. try: pin = int(input()) print("PIN code is created") except ValueError: print("Please enter a number")
6th Feb 2021, 4:00 PM
noteve
noteve - avatar
+ 7
pin = input() try: if type(int(pin)) == int: print("PIN code is created") except ValueError: print("Please enter a number") #all. test cases pased
9th May 2021, 10:40 AM
venky ch
venky ch - avatar
+ 3
No errors for me though if I input something,. Try to paste my provided code (your fixed code) to challenge and see if it will pass the test cases. # copy this: try: pin = int(input()) print("PIN code is created") except ValueError: print("Please enter a number")
6th Feb 2021, 4:31 PM
noteve
noteve - avatar
+ 1
Try to input an integer: _________________ "Looks like your program needs Input" _________________ 12345 _________________ Or if that error is from the challenges itself, then please give us a sample Input and sample Output of the challenge. Thanks.
6th Feb 2021, 4:19 PM
noteve
noteve - avatar
+ 1
ok thank you #cyan
8th Feb 2021, 6:52 AM
Dhanu Sri Mulakala
Dhanu Sri Mulakala - avatar
+ 1
I got 2 out of 4 correct with this code but can't make the other two right. so this code is partially right.. You can try. pin = input() try: type(pin)==int print("PIN code is created") except: print("please enter a number")
19th Mar 2021, 11:09 AM
Somnath Das
Somnath Das - avatar
+ 1
pin = input() try: #your code goes here if type(int(pin)) == int: print("PIN code is created") except ValueError: #and here print("Please enter a number")
18th Apr 2021, 10:10 AM
Ikan Goreng
Ikan Goreng - avatar
+ 1
pin = input() try: a=int(pin) print("PIN code is created") except ValueError: print("Please enter a number")
27th Jun 2021, 10:29 AM
Danushka
Danushka - avatar
+ 1
Try this: pin = input() try: if type(int(pin)) == int: print("PIN code is created") except ValueError: print("Please enter a number") Ask if you have questions!
17th Nov 2021, 10:29 AM
Stefan Bartl
Stefan Bartl - avatar
0
getting this as output if tried your code #cyan Traceback (most recent call last): File "/usercode/file0.py", line 3, in <module> pin=int(input()) EOFError: EOF when reading a line
6th Feb 2021, 4:15 PM
Dhanu Sri Mulakala
Dhanu Sri Mulakala - avatar
0
Exception Handling We need to create a program that allows users to create their own PIN codes for their bank cards. Each PIN code consists of digits. Complete the program so that when the user enters a character, the program stops and outputs "Please enter a number" and when the user enters only digits, the program outputs PIN code is created". Sample Input 44a5 Sample Output Please enter a number Recall int() function, that occurs an error when the argument is not a number. if input is given as 1234 for every sample it's getting pin code is created.. pls let me know wt's wrong with the code #cyan
6th Feb 2021, 4:24 PM
Dhanu Sri Mulakala
Dhanu Sri Mulakala - avatar
0
#Try this, passed all the test cases pin = input() try: if pin.isdigit(): print("PIN code is created") else: print("Please enter a number") except ValueError: print("Invalid")
5th Jun 2021, 4:18 PM
fasak_kasak