Loop

Applies to: general

A loop repeats a block of code. A counted loop (for) runs a known number of times; a conditional loop (while) runs until a condition becomes false. Loops are how programs process collections and repeat work.

total = 0
for i in range(1, 5):   # 1,2,3,4
    total += i          # accumulate -> 10

See also: recursion, array