Track 9 · Lesson 3 of 11
Catching exceptions with try and except
Handle the exceptions you expect with try/except, name them specifically, use the exception object, and avoid bare except.
You will be able to
- Wrap a risky operation in try and handle a named exception in except
- Handle several exception types with separate clauses or a tuple
- Use except ... as e to read the exception's type and message
- Explain why a bare except or except Exception hides real bugs
Included with a Formula Quest membership
It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.
View Formula Quest memberships
Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.