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

# Introduce Default Else

#### Sourcery refactoring id: `introduce-default-else`

#### Description:

Move default state of variable into `else` branch

#### Before:

```python
data = ""
if condition:
    data = dictionary["message"]
```

#### After:

```python
if condition:
    data = dictionary["message"]
else:
    data = ""
```

#### Explanation:

A common pattern when coding is to set the state of a variable based on a
condition. Often we set a default state first, then might set it to something
different if a condition holds. In these cases Sourcery will move the default
setting into the `else` branch, but only if this unlocks further changes.
