in Education by (1.8m points)
I want to raise an exception in Python and in future want to detect it using an except block, Can someone tell me how to do it?

Select the correct answer from above options

1 Answer

0 votes
by (1.8m points)
Best answer
You can use AssertionError to perform this command, follow up with the syntax given below:

if 0 < diameter <= length:

    #Do something.

elif length< diameter:

    #Do something.


    raise AssertionError("Unexpected value of 'diameter'!", diameter)

Related questions

0 votes
0 votes
asked Jan 21 in Education by JackTerrance (1.8m points)