# Loop

> Code that runs the same lines again and again. It goes until told to stop.

**Field:** Software Development  
**Category:** Programming Concepts

## Think of it like

Think of it like running laps of a track. You go round and round until the coach says stop.

## Definition

A loop runs the same lines of code again and again. Each time round is called one pass. A loop can repeat once for each item in a list, or keep going while a test stays true. Something has to end it, or it runs forever. Loops let a few lines of code handle a million items.

## Example

A shop's app loops over 500 orders in its list. For each one, it adds the price to the day's total.

## Why it matters

Computers are good at doing the same thing many times. Loops are how you ask them to.

## Common mistake

Copying the same lines ten times instead of writing one loop. A change then has to be made ten times.

## Three principles

- **Repeat the same lines.** One block runs many times.
- **Needs an end.** A list runs out, or a test turns false.
- **Scales up.** Ten items or ten million, same code.

## Related terms

- [For Loop](https://learn.benibix.com/term/development/for-loop)
- [While Loop](https://learn.benibix.com/term/development/while-loop)
- [Infinite Loop](https://learn.benibix.com/term/development/infinite-loop)
- [Break Statement](https://learn.benibix.com/term/development/break-statement)
- [Array](https://learn.benibix.com/term/development/array)
- [Iterator](https://learn.benibix.com/term/development/iterator)

## Taught in

- [For and While Loops](https://learn.benibix.com/learn/development-concepts/for-and-while-loops): Programming Basics, 11/18

---

Source: https://learn.benibix.com/term/development/loop
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
