How do I manually throw/raise an exception in Python?
Answers
Answered by
12
You can manually throw (raise) an exception in Python with the keywordraise. This is usually done for the purpose of error-checking. Consider the following example: try: raiseValueError except ValueError: print('There was an exception.')
Raise exception | Python - Geek University
Raise exception | Python - Geek University
kriti2000:
Hh
Answered by
0
1)You can manually throw (raise) an exception in Python with the keyword raise.
2)The code above demonstrates how to raise an exception.
3)You can use the raise keyword to signal that the situation is exceptional to the normal flow.
4)Notice how you can write the error message with more information inside the parentheses.
Similar questions