Python

BeginnerLesson 13 of 1930 min, hands-on

Exception Handling

Part of the Python course

You have already met errors. Every time you mistyped a name, divided by zero, or asked a list for an index that did not exist, Python stopped and printed a wall of red text. That wall is called a traceback, and the error itself is called an exception. This lesson teaches you to read those tracebacks calmly and to decide, on purpose, what your program should do when something goes wrong.

Open main.py in the editor and click the play button. You should see ...

What you'll learn

  • try
  • except
  • else
  • finally
  • raise
  • Custom exception classes
  • EAFP

Work through Exception Handling

Sign in free and open the Python course. Work through the lesson, and ask the AI tutor when you get stuck.