Both the following snippets of code do the same thing. They catch every exception and execute the code in the except: block

Snippet 1 –

try:
    #some code that may throw an exception
except:
    #exception handling code

Snippet 2 –

try:
    #some code that may throw an exception
except Exception as e:
    #exception handling code

What is exactly the difference in both the constructs?

5 Answers
5

Leave a Reply

Your email address will not be published. Required fields are marked *