Home >>Python Tutorial >Python Built-in Exceptions
There are several built-in exceptions in Python that are raised when errors occur.
Syntax:Exception | Description |
---|---|
ArithmeticError | It defines when an error occurs in numeric calculations |
AssertionError | Error raised when an assert statement fails |
AttributeError | It defines an error when attribute reference or assignment fails |
Exception | It is used to define a Base class for all exceptions |
EOFError | It is used to raise an error when the input() method hits an "end of file" condition (EOF) |
FloatingPointError | This error raised when a floating point calculation fails |
GeneratorExit | Raised an error when a generator is closed (with the close() method) |
ImportError | when an imported module does not exist then, it raised an error |
IndentationError | It Raised an error when indendation is not correct |
IndexError | This Exception Raised when an index of a sequence does not exist |
KeyError | It defines an error when a key does not exist in a dictionary |
KeyboardInterrupt | This exception raised when the user presses Ctrl+c, Ctrl+z or Delete |
LookupError | This exception raised when errors raised cant be found |
MemoryError | An error raised when a program runs out of memory |
NameError | It Raised when a variable does not exist |
NotImplementedError | It defines an error raised when an abstract method requires an inherited class to override the method |
OSError | It Raised when a system related operation causes an error |
OverflowError | It Raised an error when the result of a numeric calculation is too large |
ReferenceError | This Exception Raised an error when a weak reference object does not exist |
RuntimeError | It Raised when an error occurs that do not belong to any specific expections |
StopIteration | It Raised an iterator has no further values |
SyntaxError | It defines an error raised when a syntax error occurs |
TabError | It Raised when indentation consists of tabs or spaces |
SystemError | It Raised when a system error occurs |
SystemExit | This exception Raised when the sys.exit() function is called |
TypeError | This error is Raised when two different types are combined |
UnboundLocalError | This error is Raised when a local variable is referenced before assignment |
UnicodeError | It Raised an error when a unicode problem occurs |
UnicodeEncodeError | It raised an error when a unicode encoding problem occurs |
UnicodeDecodeError | This exception Raised an error when a unicode decoding problem occurs |
UnicodeTranslateError | It defines an error Raised when a unicode translation problem occurs |
ValueError | It Raised when there is a wrong value in a specified data type |
ZeroDivisionError | It Raised an error when the second operator in a division is zero |