0

Can we use ā€œraiseā€ statement outside the except block?

Yes / No? Why?

18th Nov 2020, 5:06 PM
AlTairTech
AlTairTech - avatar
4 Answers
+ 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