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

# Chain Compares

#### Sourcery refactoring id: `chain-compares`

#### Description

Combine two compares on same value into a chained compare

#### Before

```python
if 1 < b and b < 3:
    print("b is between 1 and 3")
```

#### After

```python
if 1 < b < 3:
    print("b is between 1 and 3")
```

#### Explanation

Two compare operations on the same value can be chained together. This is
described in detail in the
[Python comparison docs](https://docs.python.org/3/reference/expressions.html#comparisons).

Chaining compares is how they are written in mathematics and makes them easier
to read.
