**The "Crash"** The code is grammatically correct and starts running, but it encounters an operation that is impossible to execute.
**Why it happens:** The code tries to divide by zero, access a list index that doesn't exist, open a file that isn't there, or add a string to a number.
**How to handle it:**
- **Defensive Coding:** Use the existence/range checks discussed previously.
- **Try/Except Blocks:** Wrap risky code in a `try` block to catch the error gracefully instead of crashing.
```python
# --- BAD CODE (Crashes) ---
# If users input 0, this crashes with ZeroDivisionError
def get_ratio(a, b):
return a / b
# --- GOOD CODE (Handles Runtime Error) ---
def get_ratio(a, b):
try:
return a / b
except ZeroDivisionError:
print("Error: Cannot divide by zero.")
return 0
```