Lesson 05 · Python
Python Foundations: Errors, Modules & Files
Catch specific errors with try and except, raise clear failures of your own, import the standard library, and read text files safely with with.
Prerequisites: Python Foundations: Strings, Slicing & Comprehensions
Learning objectives
By the end of this lesson, you will be able to:
- Catch specific exceptions with try and except
- Order except clauses and avoid bare except
- Use else and finally for success and cleanup paths
- Raise ValueError with clear messages
- Import modules and read text files safely with with