Loop

A loop is a control structure that repeats a block of code multiple times, usually until a condition is met. Common types are for loops and while loops.

General Programming

Loops let a program do repetitive work — iterating over a list, counting, or running until something happens — without writing the same code over and over.

Examples

Python

for i in range(3):
    print(i)

Output:

0
1
2

JavaScript

for (let i = 0; i < 3; i++) {
  console.log(i);
}

Output:

0
1
2

See also

Back to the Dictionary