+ 2

PY - except SyntaxError

Does the except statement not work with SyntaxErrors??

15th Mar 2022, 3:00 AM
Nicholas Smith
2 Answers
15th Mar 2022, 3:27 AM
Simon Sauter
Simon Sauter - avatar
+ 2
Here is what I was experimenting with, but it looks like Simon answered my question. Thanks! try: print("Hello") print(1 / 0)) except ZeroDivisionError: print("Divided by zero") except SyntaxError: print('Syntax error!') finally: print("This code will run no matter what")
15th Mar 2022, 3:45 AM
Nicholas Smith