> ## 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.

# Use Assigned Variable

#### Sourcery refactoring id: `use-assigned-variable`

#### Description:

Uses a variable that was previously defined in the function instead of repeating
what was defined in the variable

#### Before:

```python
wardrobe = {"blue_hat": 1, "red_hat": 3}
for item in wardrobe:
    count = wardrobe[item]
    add_to_total(wardrobe[item])
```

#### After:

```python
wardrobe = {"blue_hat": 1, "red_hat": 3}
for item in wardrobe:
    count = wardrobe[item]
    add_to_total(count)
```

#### Explanation:

Where possible, it is preferable to re-use local variables that have been
assigned to. These variables will often have a more descriptive name that can
aid in code comprehension, and additionally re-use can reduce duplication.
