Let us take a look at how to print an exception in Python 2x and 3x versions with examples.
Example: Python 2.x
# division by zero exception
try:
result = 10 / 0
except Exception as e:
print str(e)
Output:
Example: Python 3.x
# division by zero exception
try:
result = 10 / 0
except Exception as e:
print(str(e))

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!