+ 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

4th Sep 2019, 9:30 AM
Tăng Trí Hào
Tăng Trí Hào - avatar
3 Réponses
+ 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
4th Sep 2019, 9:33 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 4
hey thx alot :) my code is working now
4th Sep 2019, 9:41 AM
Tăng Trí Hào
Tăng Trí Hào - avatar
0
Anytime! Glad it worked :)
4th Sep 2019, 9:42 AM
Aymane Boukrouh
Aymane Boukrouh - avatar