+ 1

Raising Exeptions

I didn't get the point of raising exeptions in python can you please explain more and easy to me

2nd Oct 2017, 4:50 PM
mohammad bagher
4 Answers
+ 8
Maybe this will help you understand: https://code.sololearn.com/c0iKAVH4B7wl/?ref=app
2nd Oct 2017, 5:36 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 11
An exception is raised when the interpreter encounters an operation it can't resolve. There is always an exception type associated with it. For example, a classic division by zero raises an exception ZeroDivisionError, raising a string to the power raises TypeError and so on. When building a code, you might want to intentionally raise an error of a certain type, just to make sure your program stops and does not continue to run. Especially, if it could do damage with wrong input or corrupt data. You then use the 'raise' keyword which triggers an exception to be raised. You may specify which error type to raise, too.
2nd Oct 2017, 5:22 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 2
thank you so much
2nd Oct 2017, 5:39 PM
mohammad bagher
+ 1
what do you mean from raise an exeption It the exact point that I couldn't understand
2nd Oct 2017, 5:29 PM
mohammad bagher