# IndexError: list index out of range

- **ID:** `python/indexerror-list-index-out-of-range`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Accessing an index in a list that does not exist, e.g., list of length 3 with index 5.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## Workarounds

1. **Check list length before access** (95% success)
   ```
   if len(my_list) > index: value = my_list[index]
   ```
2. **Use .get() equivalent for lists** (90% success)
   ```
   value = my_list[index] if index < len(my_list) else None
   ```

## Dead Ends

- **Using try-except to ignore IndexError** — Ignores the problem; test may pass incorrectly. (70% fail)
- **Using negative indexing blindly** — Negative indexing may access unintended elements if list length changes. (50% fail)
