# StopIteration: 

- **ID:** `python/stopiteration-next-on-empty-generator`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Calling next() on a generator or iterator that has no more items, without a default value.

## Version Compatibility

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

## Workarounds

1. **Provide default value to next()** (95% success)
   ```
   item = next(generator, None)
   ```
2. **Use for loop instead of next()** (90% success)
   ```
   for item in generator:
    process(item)
   ```

## Dead Ends

- **Catching StopIteration with a bare except** — Bare except catches all exceptions, potentially hiding other bugs. (60% fail)
- **Using list(iterator) without checking length** — list() consumes the iterator but does not handle empty case gracefully. (40% fail)
