I was taught that an empty except
catches all kinds of exceptions, but when I try this block of code it doesn't catch the exception and raise a SyntaxError
. What am I doing wrong?
try:
print "Hello"
except:
print("Caught!") #output: SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Hello")?
even when I specify the kind of exception as SyntaxError
it still doesn't catch it.
try:
print "Hello"
except SyntaxError:
print("Caught!") #output: SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Hello")?