Raising errors | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Raising errors

print(1) raise ValueError print(2) ---------------- This says we can raise errors. But why do we need to raise errors? I mean we should try that no error occurs, then why tp raise them intentionally?

16th Mar 2019, 3:10 PM
Manpreet Kaur
Manpreet Kaur - avatar
3 Answers
+ 2
Let's say you create a programme this programme can only use those people who has age greater than 18.if someone use your programme who has age less than 18 then it will raise error value error or you can choose your own name for exception like age error.so children's cannot use this programme.
16th Mar 2019, 4:52 PM
Maninder $ingh
Maninder $ingh - avatar
+ 2
Its helpful for debugging for developers and to show a not-so-geeky error to users when something wrong happens. Now when you're writing codes and running it, you get some errors bcz they're raised explicitly at the backend to make it easier for you to debug it.
16th Mar 2019, 4:53 PM
Шащи Ранжан
Шащи Ранжан - avatar
0
Maybe useful for something🏃
16th Mar 2019, 4:01 PM
Gowtham
Gowtham - avatar