Python Lab

Stage 2 · 25 min · Pro

Handling errors with try / except

Catch errors while a program runs: try, except ValueError, ZeroDivisionError, else, finally and raise.

Objectives

This lesson is for Pro members

Users will type the wrong thing: letters where a number is needed, dividing by 0. A good program doesn't crash; it reports the problem clearly and keeps running.

See Pro plans Open in the app