Python · Stage 4 – Repeating Things · Lesson 25 of 50

for Loops

Repeat once for each value in a sequence.

for color in ["red", "blue"]:
    print(color)
Line-by-line explanation
  1. The list contains two text values.
  2. for begins the loop.
  3. color temporarily holds one item at a time.
  4. The print line runs once for red and once for blue.