+ 1
Raise Exception
Can anyone please tell me what is Raise exception for? I have read comments on the Raise exception lesson but didn't catch that
2 Antworten
+ 3
Raise exception, means to cause your program's execution to stop with an error message in a specific event.
For example you can raise a ValueError when you asked for user input and you got something that won't work for your program, like you need a positive number and you got zero.
It can also be used as a control flow tool, when you "catch" the exception in a try/expect block and manipulate what should happen in the program when the error is raised.
With previous example you can expect the same error you raised before and give a default value instead of the faulty user input.
+ 2
Tibor Santa Great explanation, TY