Catching Exception | SoloLearn: Learn to code for FREE!


Catching Exception why exception block is not executing

1/21/2018 5:33:55 AM

Nitin G Dagaya

4 Answers

New Answer


print ("hello") instead of print "hello"


An error occured in the try part, so it switches to the except part instead of crashing the program. Hope it helps! num = 5 try: num = num/0 print ("hello") except: print("hello world")


SyntaxError is not a runtime error, but a compile time error, thus it cannot be caught in the code that has not been compiled.


that's exception I want to catch and print proper output in except block