+ 1
i need help with ValueError SyntaxError Output
i want to write a code to require access into the locker so im started to work on the lock 1st here is my code for the lock: user_input = input("In order to unlock, you must have a key. Please type in your key to continue: ") keycode = int(user_input) if keycode == 10042069: while True: print("Access Granted") break else: print("Access Denied") except ValueError: print("Your Key must be a number") when i execute it, it's said: except ValueError: ^ SyntaxError: Invalid Syntax please help me out with my codes, thx
3 Antworten
+ 4
You can't use except without using try.
So the code should be:
...
...
while True:
try:
#what you wrote
except ValueError:
#what you wrote
+ 4
hey thx alot :)
my code is working now
0
Anytime! Glad it worked :)