> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Remove Unused Enumerate

#### Sourcery refactoring id: `remove-unused-enumerate`

#### Description

Remove unnecessary calls to
[`enumerate`](https://docs.python.org/3/library/functions.html#enumerate) when
the index variable is not used.

#### Before

```python
for index, hat in enumerate(hats):
    print("I like this hat: ", hat)

for i, (key, value) in enumerate(my_dictionary.items()):
    do_something(key)
    do_something_else(value)

beautiful_hats = [hat for hat_id, hat in enumerate(hats) if is_beautiful(hat)]
```

#### After

```python
for hat in hats:
    print("I like this hat: ", hat)

for key, value in my_dictionary.items():
    do_something(key)
    do_something_else(value)

beautiful_hats = [hat for hat in hats if is_beautiful(hat)]
```

#### Explanation

Enumerating iterables with
[`enumerate`](https://docs.python.org/3/library/functions.html#enumerate) is a
good practice for having access to both the values and their respective indices.
However, when the indices are not necessary, it is cleaner to simply iterate
over the original iterable and remove the call to `enumerate`.
