Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
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
asked Mar 3, 2021 in Python by laddulakshana (16.4k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...