Catching Exception | SoloLearn: Learn to code for FREE!

+1

Catching Exception

https://code.sololearn.com/ce6m8vXTUZxU/?ref=app why exception block is not executing

1/21/2018 5:33:55 AM

Nitin G Dagaya

4 Answers

New Answer

+5

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

+5

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")

+1

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

0

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