Exceptions
Learn about the exceptions in Python.
We'll cover the following
Overview
Python’s normal behavior is to execute statements in the order they are found, either in a file or at the prompt interactively. A few statements, specifically if
, while
, and for
, alter the simple top-to-bottom sequence of statement execution. Additionally, an exception can break the sequential flow of execution. Exceptions are raised, and this interrupts the sequential execution of statements.
Types of exceptions
In Python, the exception that’s raised is also an object. There are many different exception classes available, and we can easily define more of our own. The
one thing they all have in common is that they inherit from a built-in class called BaseException
.
Get hands-on with 1400+ tech skills courses.