+ 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")
12 ответов
+ 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")
+ 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
+ 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")
+ 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.
+ 1
ok thank you #cyan
+ 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")
+ 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")
+ 1
pin = input()
try:
a=int(pin)
print("PIN code is created")
except ValueError:
print("Please enter a number")
+ 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!
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
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
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")