Course Content

If you are facing any issue in playing video please use Firefox browser.

Course Content


Exception Handling in Python 2


In this lecture we will see that,

How to perform exception handling in Python ?

How to raise the exception ?





except Exception:

print('You cannot enter string')

print('Good Bye')

O/P :


You cannot enter string

Good Bye


Similarly we can use all the error blocks in one code and it will execute one error block according to the action.


Try .....finally clause


Finally clauses are called clean-up or termination classes, because they must be executed under all circumstances, ie. a "finally" clause is always executed regardless if an exception occurred in a try block or not.




To explicitly raise exception at that time we can use raise.


raise Exception()

raise Exception("Something happened in my program")


Example :


if c>5:

raise Exception ("c has to be less than 5")


O/P :

Exception : c has to be less than 5




Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere