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

# Min/Max identity

#### Sourcery refactoring id: `min-max-identity`

#### Description:

Replaces duplicate conditionals looking for the minimum or maximum value of
multiple variables with a `min` or `max` function

#### Before:

```python
if first_hat.price < second_hat.price:
    cheapest_hat_price = first_hat.price
else:
    cheapest_hat_price = second_hat.price
```

```python
if sale_price >= 10:
    sale_price = 10
```

#### After:

```python
cheapest_hat_price = min(first_hat.price, second_hat.price)
```

```python
sale_price = min(sale_price, 10)
```

#### Explanation:

We often need to work out the smallest or largest of two values, and the
quickest way to do this in Python is to use the built-in `min` and `max`
functions. This results in a shorter and clearer way to achieve the same result.
The same functions also offer a shortcut for when we want to put a cap or a
floor on the value of a variable.
