Standard Exceptions In Python

In this tutorial, we will learn the Standard Exceptions in Python. Basically here we learn about the types of Errors that have been rising due to our improper code. If we understand with this then we will correct or understand with the Errors that might be generated in our compiler.

Learn: Handling Exceptions using try and except in Python 3.x. or earlier

List of Standard Exceptions in Python with description

Now we have to see the types of errors. Here we have listed some Important type of Exceptions with their description:

  1. StopIteration : It raised when the next() method in iterator does not point to any object or we can say when the number of items is not present in the container for the next() method.
  2. SystemExit : This is raised when the sys.exit() function does not use carefully or fails to work.
  3. FloatingPointError : It raised when the calculation involves floating-point fails.
  4. ZeroDivisonError : This raised when we divide the number by zero.
  5. AssertionError : raised when the Assert statement fails.
  6. ImportError : Raised if the import statement fails.
  7. IndexError: Raised if the index is not found in the given sequence.
  8. KeyError : Raised if the specified key appears to be not found in the given dictionary.
  9. IndentationError : When we don’t provide the proper indentation.
  10. TypeError : Raised when we give the wrong input to the program like an integer in place of a name.
  11. ValueError : Raised when we provide the invalid values to the argument that specified to the built-in function.
  12. RuntimeError: This error raised when the generated error does not fall into any type of category.
  13. KeyboardInterrupt : When we run our code and by mistake, we press the wrong key then this error is raised.
  14. UnboundLocalError : This error is raised when we want to access the local variable that we have created but we have to forget to assign value to it.
  15. SyntaxError : When the written code does not according to the python syntax then this error is raised.
  16. SystemError: This error is raised when the interpreter finds some system-related problems.
  17. ModuleNotFoundError: It raised when the import statements unable to load the specified module.
  18. RecursionError: It raised when the recursion depth exceeds its limiting value.
  19. ReferenceError: This raised when the generated error does not fall in any of the categories.
  20. TabError : Raised when the given indentation contains some extra or unwanted tabs and spaces.

Thanks for reading. For more information about Python you can visit the following links:

Augmented assignment in Python

User-Defined Errors In Python

Leave a Reply

Your email address will not be published. Required fields are marked *