Start free

Browse › Introductory Python

Handle Errors and Exceptions in Python

Guided

Part of Introductory Python Topic: Programming

Access

StationX Infrastructure Labs — 3 attempts per lab

🔒 Add StationX Infrastructure Labs — $149 / year · 3 attempts per lab

Already have access? Sign in.

New to this? Try a free practice lab — a scripted hacking challenge in your browser, no account needed.

What you'll do

In this lab, you will handle errors and exceptions in your code.

  1. Find a logical error in a function
  2. Refactor the function so that it does not cause any errors
  3. Write code that contains an error
  4. Add a try/except block to handle exceptions
  5. Add a try/except block that handles multiple exceptions
  6. Add an else clause to handle code that must run without any exceptions

Note: Once you begin the lab, you will not be able to pause, save, or exit and then return to your lab. Please ensure that you have set aside enough time to complete the lab before you start.

  • ⏱ About 45 minutes
  • Counts towards: Introduction to Python

Roadmaps that use this lab