Collection traversal
Process every element in a collection.
Python · Const
The for statement repeats a suite for each element produced by a sequence or other iterable. It binds each element to a target and supports break, continue, and an optional else clause.
A for statement obtains an iterator from its iterable and assigns each yielded value to the target before running the indented suite. It can include else, which runs if iteration finishes normally rather than through break.
for target_list in expression_list:
suite
[else:
suite]for to process values from sequences and other iterable objects.for is a compound control-flow statement.for item in items:
print(item)Prints each item from the iterable in iteration order.
Process every element in a collection.
Read each record from a generator or file.
Perform an action for each value in a numeric range.
whilebreakcontinueelse clauseiterablerange