Advertisements
Advertisements
Question
Define the following:
Throwing an exception
Short/Brief Note
Advertisements
Solution
Throwing an exception means raising an exception.
Each time an error is detected in a program, the Python interpreter raises (throws) an exception. Exception handlers are designed to execute when a specific exception is raised.
Programmers can also forcefully raise exceptions in a program using the raise and assert statements. Once an exception is raised, no further statement in the current block of code is executed.
raise NameError
assert conditon, "message"shaalaa.com
Handling Exceptions in Python
Is there an error in this question or solution?
