You’ve seen various exceptions raised by your Python code. Sometimes you might need to write functions that raise exceptions to inform callers of errors that occur. The raise
statement explicitly raises an exception. The simplest form of the raise
statement is
raise ExceptionClassName
The raise
statement creates an object of the specified exception class. Optionally, the exception class name may be followed by parentheses containing arguments to initialize the exception object—typically to provide a custom error message string. Code that raises an exception first should release any resources acquired before the exception occurred. In the next section, we’ll show an example of raising an exception.
In most cases, when you need to raise an exception, it’s recommended that you use one of Python’s many built-in exception types9 listed at:
https:/ / docs.python.org/ 3/ library/ exceptions.html
(Fill-In) Use the statement to indicate that a problem occurred at execution time.
Answer: raise
.