Common Python runtime and syntax errors, their causes, and how to fix them.
Operation applied to an object of the wrong type.
Function receives an argument with the right type but inappropriate value.
Accessing a list, tuple, or string with an out-of-range index.
Accessing a dictionary with a key that does not exist.
Accessing an attribute or method that doesn't exist on an object.
Using a variable or function name that hasn't been defined.
Python cannot locate the requested module or package.
Incorrect spacing or mixing tabs and spaces in code blocks.
Modifying an outer variable inside a function without explicit global or nonlocal keywords.
Attempting arithmetic division or modulo operation with zero as the divisor.
A recursive function calls itself indefinitely without hitting a valid base case.
Attempting to access a method or property on a variable that evaluated to None.
File system operation blocked due to lack of OS read/write privileges or locked file.
Attempting to open or process a file at a path that does not exist in the file system.
Parsing a string with json.loads() fails because the string does not conform to valid JSON format.