5.1 Types of Exceptions/Errors

In Python there are three main types of exceptions/errors that a programmer has to deal with. There are different ways to handle each one according to their types, but first let's go through them.

1. Compile Time Errors

2. Runtime Error

Some common runtime errors in Python.

  1. >AttributeError: Raised when an attribute reference or assignment fails.
  2. >TypeError: Raised when an operation or a function is applied to an object of inappropriate type.
  3. >ValueError: Raised when an operation or a function receives an argument that has the right type but an inappropriate value.
  4. >RecursionError: Raised when the maximum recursion depth is exceeded, also called StackOverFlow error.
  5. >IndexError: Raised when a sequence subscript is out of range.
  6. >KeyError: Raised when a mapping (dictionary) key is not found in the set of existing keys.

3. Logical Error