Computer Science, asked by HarshaVardhan7407, 1 year ago

How do I manually throw/raise an exception in Python?

Answers

Answered by kriti2000
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


kriti2000: Hh
veersingh63: hii
veersingh63: hey liza
veersingh63: sorry
veersingh63: hii
veersingh63: okkkkk sorry
veersingh63: byee
veersingh63: nss
bhj1: hi cutie
Answered by liza10987654321
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.


veersingh63: hii
veersingh63: liza
veersingh63: what happened
veersingh63: hey liza
bhj1: hi liza
Similar questions