pythonreference.com

search statements, functions, methods, exceptions*

show categories

'for' with a list, tuple or set
iterate over each item in a container
items = ['a', 'b', 'c']

for item in items:
    print(item)
Argument(s):
N/A (iterates over list, tuple or set)
Return value(s):
with each iteration, object from the container is assigned to the loop variable
as Python iterates over each item in a container, it assigns the item to the loop variable (in the example, 'item'), then executes the block. The assignment and block execution happen once for each item in the container.