+ 2

is raising exceptions like creating our own exceptions? if no can someone explains to me "raising exceptions"?

14th Jul 2016, 10:06 AM
souhaila
2 Respostas
+ 8
Not all the time. You have the choice to raise an already existing exception or raise your own. E.g if input () not in "0123456789": raise ValueError("not a number") else:print ("is a number") or raising your own exception class NotSeven (Exception): def __init__(self): Exception.__init__(self, "Input number is not seven") if input () != "7": raise NotSeven() else:print ("Good, the number is seven.")
16th Jul 2016, 9:01 AM
Gershon Fosu
Gershon Fosu - avatar
0
thank you 😀😀
16th Jul 2016, 9:44 AM
souhaila