# Short-Circuit Evaluation

say it: **“SHORT SUR-kit ih-val-yoo-AY-shun”** **/ˈʃɔrt ˈsɜrkɪt ɪˌvæljuˈeɪʃən/**

Python stops checking an and/or as soon as it knows the answer.

## What is **short-circuit evaluation**?

**Short-circuit evaluation** means Python stops checking an `and` or `or` as soon as it knows the answer. You can use it to check something is safe before using it.

```python
cart = []
# len(cart) > 0 is False, so cart[0] is never checked (no error)
if len(cart) > 0 and cart[0] == "gift card":
    print("Gift card first")
```

Level: Apprentice · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=2)

Updated: November 17, 2026

## In other subjects

- [Short-Circuit Evaluation in C#](https://www.ask-codey.com/glossary/short-circuit-evaluation-c-sharp)

Source: https://www.ask-codey.com/glossary/short-circuit-evaluation
