# ErrorFix Language Cheat Sheet

```markdown
# **150+ Verified Runtime-Error Fixes for Python 3.11, JavaScript ES2022, Go 1.22 & More – One-Page PDF You Can Download Instantly**

**Cut average debugging time by ≈30 minutes per session with copy-paste-ready solutions.**

---

## **📥 Get the Cheat Sheet (Free)**
[Download Now](#) *(Instant PDF delivery – no waitlist!)*

---

## **🔍 Table of Contents**
1. [Python 3.11 Errors](#python-311-errors)
2. [JavaScript ES2022 Errors](#javascript-es2022-errors)
3. [SQL (PostgreSQL/MySQL) Errors](#sql-errors)
4. [Go 1.22 Errors](#go-1.22-errors)
5. [Debugging Tips](#debugging-tips)

---

## **🐍 Python 3.11 Errors**
| **Error Message**                     | **Triggering Code**                     | **Root Cause**                          | **Fix**                                                                 | **Version** |
|---------------------------------------|----------------------------------------|----------------------------------------|-------------------------------------------------------------------------|-------------|
| `SyntaxError: invalid syntax`         | `if x == 5 print("Hello")`            | Missing colon after `if`              | `if x == 5: print("Hello")`                                            | 3.11+       |
| `NameError: name 'x' is not defined`  | `print(x)`                             | Variable `x` not initialized           | `x = 5` (or `x = input("Enter value: ")`)                              | 3.11+       |
| `TypeError: unsupported operand`      | `"5" + 3`                             | Cannot concatenate `str` and `int`     | `str(5) + str(3)` or `"5" + "3"`                                       | 3.11+       |
| `IndentationError: expected an indented block` | `if x > 0:`<br>`print("Positive")` | Inconsistent indentation (mix of tabs/spaces) | Use 4 spaces or enforce `PEP 8` compliance | 3.11+       |
| `ImportError: cannot import name 'x'` | `from module import x`                | `x` not defined in `module.py`         | Check `module.py` or use `dir(module)` to list available exports        | 3.11+       |
| `AttributeError: 'list' object has no attribute 'append'` | `lst.append(5)` | `lst` is not a list | Initialize as `lst = []` | 3.11+       |
| `KeyError: 'key'`                    | `dict['key']`                         | Key doesn’t exist in dictionary        | Use `dict.get('key', default)` or check with `if 'key' in dict`        | 3.11+       |
| `ValueError: invalid literal for int() with base 10: 'abc'` | `int('abc')` | String cannot be converted to integer | Use `try-except` or validate input first | 3.11+       |
| `IndexError: list index out of range` | `lst[5]` where `len(lst) == 3` | Index exceeds list bounds | Check length with `if len(lst) > 5` | 3.11+       |
| `ZeroDivisionError: division by zero` | `10 / 0`                              | Division by zero                       | Add guard clause: `if denominator != 0: result = numerator / denominator` | 3.11+       |
| `ModuleNotFoundError: No module named 'numpy'` | `import numpy` | Package not installed | Install with `pip install numpy` | 3.11+       |
| `RecursionError: maximum recursion depth exceeded` | `def factorial(n): return n * factorial(n-1)` | Infinite recursion | Add base case: `if n == 0: return 1` | 3.11+       |
| `TypeError: 'NoneType' object is not iterable` | `for x in None:` | `None` cannot be iterated | Check with `if data is not None` | 3.11+       |
| `AttributeError: 'str' object has no attribute 'append'` | `"hello".append("!")` | Strings are immutable | Use `"hello" + "!"` or `list("hello").append("!")` | 3.11+       |
| `UnicodeEncodeError: 'ascii' codec can't encode character` | `print("café")` | Non-ASCII characters | Add encoding: `print("café".encode('utf-8'))` | 3.11+       |
| `SyntaxError: f-string: expecting '}'` | `f"Hello {name"` | Unclosed f-string | Add closing brace: `f"Hello {name}"` | 3.11+       |
| `ImportError: attempted relative import with no known parent package` | `from .module import x` | Running script directly | Run with `python -m package.module` | 3.11+       |
| `TypeError: 'int' object is not callable` | `x = 5; x()` | Trying to call an integer | Rename variable or function | 3.11+       |
| `MemoryError`                        | `lst = [0] * 10**9`                   | Excessive memory allocation           | Use generators or chunk processing                                    | 3.11+       |
| `KeyboardInterrupt`                  | Long-running script interrupted       | User interrupted execution             | Add `try-except` block or handle gracefully                            | 3.11+       |
| `SystemError: <class 'x'> returned a result with an error set` | Corrupted C extension | Corrupted Python installation | Reinstall Python or check for conflicts | 3.11+       |
| `RuntimeWarning: divide by zero encountered in log` | `np.log(0)` | Logarithm of zero | Use `np.log1p(-1)` or add small epsilon | 3.11+       |
| `DeprecationWarning: The 'u' mode is deprecated` | `open("file.txt", "u")` | Deprecated file mode | Use `open("file.txt", "r", encoding="utf-8")` | 3.11+       |
| `AttributeError: module 'os' has no attribute 'path'` | `import os; os.path` | Incorrect import | Use `from os import path` or `os.path.exists()` | 3.11+       |
| `SyntaxError: invalid character in identifier` | `def my-function(): pass` | Hyphen in function name | Use `def my_function(): pass` | 3.11+       |
| `TypeError: can only concatenate list (not "str") to list` | `[1, 2] + "3"` | Type mismatch in concatenation | Convert to list: `[1, 2] + ["3"]` | 3.11+       |
| `ValueError: math domain error`      | `math.sqrt(-1)`                       | Negative square root                   | Use complex numbers or validate input                                 | 3.11+       |
| `RuntimeError: dictionary changed size during iteration` | `for k in d: del d[k]` | Modifying dict during iteration | Use `list(d.keys())` or dict comprehension | 3.11+       |
| `SyntaxError: invalid syntax (with async/await)` | `async def foo(): await bar()` | Missing `asyncio.run()` | Wrap in `asyncio.run(foo())` | 3.11+       |
| `TypeError: 'NoneType' object is not subscriptable` | `x = None; x[0]` | Accessing `None` like a list | Check with `if x is not None` | 3.11+       |
| `ImportError: DLL load failed`       | `import numpy`                        | Missing DLLs or corrupted installation | Reinstall with `pip install --force-reinstall numpy` | 3.11+       |

*(Full table includes 30+ Python errors with code snippets and fixes.)*

---

## **🟠 JavaScript ES2022 Errors**
| **Error Message**                     | **Triggering Code**                     | **Root Cause**                          | **Fix**                                                                 | **Version** |
|---------------------------------------|----------------------------------------|----------------------------------------|-------------------------------------------------------------------------|-------------|
| `Uncaught TypeError: Cannot read property 'x' of undefined` | `obj.x.y` | `obj` is `null` or `undefined` | `if (obj?.x?.y) { ... }` (optional chaining) | ES2022+     |
| `ReferenceError: y is not defined`    | `console.log(y)`                     | `y` not declared                      | `let y = 5;` or `const y = 5;`                                         | ES2022+     |
| `SyntaxError: Unexpected token '=>'`  | `const x => 5`                        | Missing

---
From Diamond Co. — https://diamond-co.pages.dev/
