Python Quest

Track 9 · Lesson 5 of 11

Raising exceptions

Signal problems from your own functions with raise, choose the right exception type, write messages that help, and re-raise or chain when translating errors.

About 40 minIntermediate4 exercises

You will be able to

  • Raise a built-in exception with raise and an informative message
  • Choose between ValueError, TypeError and KeyError for a given problem
  • Explain why raising is better than returning an error string or a magic value
  • Re-raise an exception with a bare raise, and translate one with raise ... from

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.