0

Can we use “raise” statement outside the except block?

Yes / No? Why?

18th Nov 2020, 5:06 PM
AlTairTech
AlTairTech - avatar
4 Respuestas
+ 3
You can, but you should try and catch your errors. The whole point of raise is when you don't want to allow certain input. If there's a program that takes input, but it should only take letters, and numbers were entered, python sees nothing wrong with this. There can be a check to see if any numbers were entered and if so, raise an error to say so
18th Nov 2020, 5:25 PM
Slick
Slick - avatar
+ 2
Yes you can use it outside the except block. Why? That's the way the programming language was written 😃 It is a good explanation given by Slick . To disallow certain events (inputs) from happening. Here's a quick example of its usage Happy Coding 😀 https://code.sololearn.com/cc37rZ3tw8AN/?ref=app
18th Nov 2020, 6:08 PM
Tomiwa Joseph
Tomiwa Joseph - avatar
+ 1
I get it now! 🤦🏾‍♂️ thank you Slick 👍🏽
18th Nov 2020, 6:58 PM
AlTairTech
AlTairTech - avatar
0
got it mate Tomiwa Joseph 👍🏽
18th Nov 2020, 7:00 PM
AlTairTech
AlTairTech - avatar