How to handle special cases in my Python code?

I didn’t read your code, on the account of it being too long, and was confused by what you wanted, on the account of it being non-descriptive (no offense). But you ask “How am I suppose to make an exception?” You can make a custom exception with Exception as your superclass (is this the correct terminology?). Look at this for an example:

class MyError(Exception): #exception names usually end with 'Error'
    pass

This should be the way to start making a custom exception, and you can learn more later. Hope this helps slightly.

EDIT:
Remember not to create any custom exceptions that have a similar built-in exception, such as ZeroDivisionError.

Leave a Comment