Loop evaluation
Visit a sequence with just one entry
The iterable is evaluated when the loop starts. Each iteration then reads the next value.
for value in [42]:
print(value)
42
There is only one item, so the body runs once.
A for source expression is evaluated once per loop entry. Iterables include ordinary collections and modules, text, packed sequences and ranges. One binding gets the value. Two bindings get index/key and value. Range values can start at a negative integer. Range iteration keys always start at zero. while re-evaluates its condition at each iteration. An if/elif chain selects its first truthy branch. break and continue require an enclosing loop in the same function.