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

# Ternary to If Expression

#### Sourcery refactoring id: `ternary-to-if-expression`

#### Description

Replace boolean ternary with inline if expression.

#### Before

```python
protocol = is_ssl and "https" or "http"
```

#### After

```python
protocol = "https" if is_ssl else "http"
```

#### Explanation

Prior to Python version 2.5 the best way to create a ternary operator was to use
`and` & `or` together in the before example.

The if expression syntax shows the intent of the code much clearer and so is
preferred.
