Question regarding raising Exception
When we try to raise exception using "raise TypeError("Only integers are allowed") "
Why the except block didn't run??
Did we already encounter the exception and we don't need except block we raise that in Try block???
1 answers ( 0 marked as helpful)
Hey Mayank,
Thank you for reaching out!
The purpose of the raise
command is to raise an exception and then terminate the program immediately after. That is why we don't reach the except
statement in the code.
Kind regards,
365 Hristina