Course Content

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

Course Content

Description

How To Implement User Defined Exception in Python

 

In this lecture we will see,

How to implement user defined exception in Python ?

 

User defined Exception

 

Python also allows you to create your own exceptions by deriving classes from the standard built-in exceptions.

 

class MyNewError(Exception):

pass

raise MyNewError("Something happened in my program")

 

Example :

class MyException(Exception):

pass

c=6

if c=5:

raise MyException ("Something went wrong")

O/P :

MyException: Something went wrong

FAQs

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