Login
📚 Introduction to Python Programming
Chapters ▾
⇩ Download ▾

14.5 Raising exceptions

Learning objectives

By the end of this section you should be able to

  • Use a raise statement to indicate that user input is invalid.
  • Explain the flow of execution when an exception is raised.

The raise statement

A program can raise an exception when an error is detected. Raising an exception forces a program to deal with the error. If the exception is not handled using try and except, the program displays an error message and terminates.