Exercises Python logo
Exercises Python
Course Practice Editor Get started free
  1. Python course
  2. Error and Exception Handling
  3. What is an exception in Python?
20 Error and Exception Handling
Fundamentals concepts
  • What is an exception in Python?
  • The try-except structure
  • else, finally and the complete structure
  • Exception types and how to read an error
  • Raising exceptions and creating your own
  • Best practices and common mistakes
  • Chaining exceptions and adding notes
  • Exception groups and except*
Practice exercises
  • Zero division capture
  • Handling multiple exceptions
  • Safe integer
  • Safe index
  • Retry until valid
  • Validated square root
  • Custom exception
  • Calculator with finally
  • Chained errors
  • The order of try, else and finally
  • Exception groups
  • Retries with a custom error
X (Twitter) Facebook LinkedIn WhatsApp Telegram Reddit Email
Error and Exception Handling · 1 / 20 Theory

What is an exception in Python?

An exception is an event that interrupts the normal flow of a program. Python raises exceptions when a runtime error occurs, such as division by zero or accessing an undefined variable. These exceptions can be caught and handled to prevent the program from crashing.
←Back to lesson Next →The try-except structure
Exercises Python logo
Exercises Python

Learn Python by solving practical exercises, free and right in your browser.

Get it on Google Play

Learn

  • Home
  • Course
  • Practice
  • Editor

More

  • Features
  • Contact

Account

  • Log in
  • Sign up

Legal

  • Privacy policy
  • Cookies policy
  • Terms and conditions
  • Cookie settings
  • Sitemap

© 2026. Made with 💙 by Jaracoder.

English
  • Español

We use necessary cookies to keep your session. With your consent we also use cookies for advertising and analytics, which keep the course free and help us improve it. Cookies policy