Stage 2 · 25 minutes · Pro
Error handling with try / except
Catch errors while a program runs: try, except ValueError, ZeroDivisionError, else, finally and raise.
Objectives
- Tell syntax errors and runtime errors apart
- Catch specific errors with except
- Use else and finally
- Raise your own errors with raise
Lesson for Pro members
Users will type wrong input: letters when a number is needed, division by 0. A good program does not 'crash' but reports the error clearly and keeps running.
View Pro plans Open in the app