Python Built-in Exceptions

Exception NameDescription
SyntaxErrorRaised when there is a syntax error in the code.
IndentationErrorRaised when there is an indentation error.
NameErrorRaised when a local or global name is not found.
TypeErrorRaised when an operation or function is applied to an object of an inappropriate type.
ValueErrorRaised when a function receives an argument of the correct type but an inappropriate value.
KeyErrorRaised when a dictionary does not have a specified key.
IndexErrorRaised when a sequence (list, tuple, string, etc.) index is out of range.
FileNotFoundErrorRaised when a file or directory is not found.
ZeroDivisionErrorRaised when division or modulo operation is performed with zero as the denominator.
AttributeErrorRaised when an attribute reference or assignment fails.
IOErrorRaised when an input/output operation fails.
EOFErrorRaised when the input() function reaches the end of file (EOF) condition.
KeyboardInterruptRaised when the user interrupts the program (usually by pressing Ctrl+C).
ModuleNotFoundErrorRaised when an imported module is not found.
ImportErrorRaised when an import statement cannot locate the specified module.
ValueErrorRaised when a function receives an argument of the correct type but an inappropriate value.