Catch the syntaxError exception in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Catch the syntaxError exception in python?

Hello All, I am just wondering how can we catch syntax error exception in python? Attached a sample code to do that. Any one from solo learn knows better way to do this? Please suggest. Thanks, SagaTheGreat ๐Ÿ’ฏ https://code.sololearn.com/cP3X3COfu8Z4/?ref=app https://code.sololearn.com/cP3X3COfu8Z4/?ref=app

25th Jun 2018, 5:16 PM
$ยข๐Žโ‚น๐”ญ!๐จ๐“
$ยข๐Žโ‚น๐”ญ!๐จ๐“ - avatar
2 Answers
+ 3
The only catchable syntax errors is within an eval or exec. All others occur prior to the execution of your code so can't be caught.
25th Jun 2018, 8:45 PM
John Wells
John Wells - avatar
+ 2
the only thing you can use to check a syntax error is your eyes and brain
25th Jun 2018, 5:54 PM
hinanawi
hinanawi - avatar