for loop
A loop that runs once for each item in a sequence.
for fruit in ["apple", "pear", "plum"]:
print(fruit.upper())
for i in range(3): # 0, 1, 2
print("row", i)
Output
APPLE PEAR PLUM row 0 row 1 row 2
Where this shows up in real Python
For loops process each file in a folder, each row in a CSV, each result from an API — anywhere you handle a collection one item at a time.
Common for-loop tools
range(n)— loop a fixed number of timesenumerate(seq)— loop with an indexzip(a, b)— loop two sequences togetherbreak / continue— stop early / skip an itemfor k, v in d.items()— loop a dictionary’s pairs
Official documentation: Python Tutorial: for Statements