+ 2
Can I make my own exceptions in python?
Example: if user has to input his name...and user input name of len(1) then i want that it show NameTooShortError(This is not default error).
4 Réponses
+ 4
You may want to use a if statement
Here’s what you asked for: http://www.sololearn.com/app/JUMP_LINK__&&__python__&&__JUMP_LINK/playground/cI4mcQVKHsy1/
+ 4
" Python Custom Exceptions(examples included)"
https://www.programiz.com/python-programming/user-defined-exception
" User-defined Exceptions in Python with Examples"
https://www.geeksforgeeks.org/user-defined-exceptions-python-examples/amp/
+ 2
you could use if statement and just print error message or
if you want it to exit with an exception, if i don't remember incorrectly you can just do
raise Exception("error string here")
or you could make a custom class/function