for repeats part of a program.
It repeats commands that are indented after
It's the same as with
if - it applies only to
commands that are indented below.
for x in range(n): repeats the commands below n times
and it increments the variable
x gradually from 0 to n-1.
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.