0
Exception Handling Concept
Hi, Can you please share the output of this code? also please describe the reason . Thanks! try: print(d''1/0) except invalid syntax: print(2) finally: print(3)
4 Respuestas
+ 3
Syntax error can not be catched with try ... except (only by working with eval() or exec()). Syntax error raise during the parser run before the code will be executed. So syntax errors must be fixed in any case before the program run.
+ 5
Abhishek
There is indeed a syntax error in your try block, plus, there is no exception named invalid syntax. You can just write except: if you don't know the type of error the code will encounter.
Check this out for list of errors in Python and go through this tutorial
https://www.sololearn.com/learn/Python/2441/?ref=app
https://code.sololearn.com/cM1FBEbiZvk0/?ref=app
+ 1
ok , lets try same code with using except only?
try:
print(d''1/0)
except:
print(2)
finally:
print(3)
but this code also not executing
+ 1
Thanks ...i got the point