Skip to main content

Adding Exception Handling to a Python Script

Hands-On Lab


Photo of

Training Architect





Our code won't always be able to run without issue. So many things can go wrong when running code — network connectivity can fail, file system permissions can be wrong, bad inputs can be passed to our scripts. Thankfully, we can normally tell when these types of issues might happen in our code and we can handle them. In this hands-on lab, we'll add exception handling to an existing script that can run into many of these issues. To feel comfortable completing this lab, you'll want to know how to perform exception handling in Python (watch the "Handling Exceptions with try, except, else, and finally" video from the Certified Associate in Python Programming Certification course).

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.