By the end of this chapter, you will be able to:
- Describe what errors and exceptions are
- Handle errors and exceptions when they occur
- Define and use your own custom exceptions
This lesson describes error handling in Python. We look at the try…except clause and its modified types. Lastly, we cover custom exceptions. Solutions for the activities in this lesson can be found on page 289.
In life, things sometimes do not go according to plan. You may find, for example, that you have budgeted to buy some things for when you go to the store. But when you actually arrive at the store, you see some items that are not on your list are on sale and you buy them! That is an incident where the initial ...