Python exceptions: try, except, else, finally: activity sheet
Goal: See which blocks of a try statement run for good input, handled errors and unhandled errors.
You need: Only the simulation is needed. You can repeat it in Python with a short script.
Safety: No special safety needs.
- Run int(text) with input 12 and note the blocks.
- Run it with abc and the right except clause.
- Remove the except clause and note what happens.
- Turn finally on and off and say what changes.
| Statement and input | Handler | Blocks that ran |
|---|---|---|
Use your browser's Print option to print this page.