Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (1.6k points)

try:

    something here

except:

    print 'the whatever error occurred.'

How can I print the error/exception in my except: block?

2 Answers

0 votes
by (25.1k points)

You can print an exception like this:

try:

    something here

except Exception as e:

    print(e)

0 votes
by (106k points)

To print an exception in Python you can use below-mentioned code:-

except Exception as e: 

print(e)

Related questions

0 votes
2 answers
asked Oct 15, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...