The command for
repeats part of a program.
It repeats commands that are indented after for
.
It's the same as with if
- it applies only to
commands that are indented below.
The command for x in range(n):
repeats the commands below n times
and it increments the variable x
gradually from 0 to n-1.
The command for x in a, b, c, d, ...:
repeats the commands below;
it changes the variable x
gradually to a, b,
c d, ...
In computer programming, a loop is a sequence of instructions that is continually repeated until a condition is reached. Very powerful concept allowing you to significantly reduce duplication of commands.