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

# Simplify-Constant-Sum

#### Sourcery rule id: `simplify-constant-sum`

#### Description

Simplify constant sum() call


#### Before

```python
sum(1 for book in books if book.author == "Terry Pratchett")
```

#### After

```python
sum(bool(book.author == "Terry Pratchett") for book in books)
```



#### Explanation

As `sum` add the values it treats `True` as `1`, and `False` as `0`. We make use
of this fact to simplify the generator expression inside the `sum` call.
