Python Errors
Brandon Krakowsky
Python Errors
Property of Penn Engineering |
Common Error Types
Here are some common types of errors in Python
• SyntaxError: the syntax (or structure) of the code is incorrect
• IndentationError: the indentation (or spacing) of the code is incorrect
• EOFError: end of file error, caused by reaching the end of an input when trying to read data
• AssertionError: assert statement fails, e.g., when asserting that one value is equal to (or not
equal to) another value in a unit testing method
• ValueError: a function receives an argument with an inappropriate value
• NameError: use of a variable or function name that is not valid (or doesn’t exist)
Ref:
• https://docs.python.org/3/tutorial/errors.html
• https://docs.python.org/3/library/exceptions.html
Property of Penn Engineering |
Common Error Types
Here are some common types of errors in Python
• TypeError: an operation or function is applied to a value with an inappropriate data type
• IndexError: an index is out of range in a sequence, e.g., a list
• KeyError: a key is not found in a dictionary
• KeyboardInterrupt: execution of code is interrupted by the user
• MemoryError: an operation runs out of memory.
• ZeroDivisionError: division (or modulo operation) by zero
Ref:
• https://docs.python.org/3/tutorial/errors.html
• https://docs.python.org/3/library/exceptions.html
Property of Penn Engineering |