For loops and range

A `for` loop runs its body once for each item of a sequence, and `range(a, b)` counts from `a` up to but not including `b`, which is why `range(n)` runs exactly `n` times.

From Introduction to Computer Science.