# while Loop

*noun*

say it: **“WYL loop”** **/ˈwaɪl lup/**

A loop that keeps repeating its block as long as its condition is true, checking the condition before each round.

## What is a **while loop**?

A **while loop** keeps repeating as long as its condition stays true.

```python
fuel = 3
while fuel > 0:
    print("Driving... fuel left:", fuel)
    fuel -= 1
print("Out of fuel")
```

## In a sentence

- “The **while loop** kept asking for a PIN until the user typed the right one.”
- “A **while loop** whose condition never turns false runs forever.”

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

Updated: November 19, 2026

## In other subjects

- [while Loop in C#](https://www.ask-codey.com/glossary/while-loop-c-sharp)
- [while Loop in Java](https://www.ask-codey.com/glossary/while-loop-java)
- [while Loop in JavaScript](https://www.ask-codey.com/glossary/while-loop-javascript)
- [while Loop in PowerShell](https://www.ask-codey.com/glossary/while-loop-powershell)
- [while Loop in Unix](https://www.ask-codey.com/glossary/while-loop-unix)

Source: https://www.ask-codey.com/glossary/while-loop
