← back to unit
Easy
# basics loops
Looping Over a List
Just like a string, a for loop can go directly over a list, one item at a time:
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print(fruit)
prints:
apple
banana
cherry
Your turn: a list called colors containing ["red", "green", "blue"] is given. Loop through colors and print each color on its own line.
💡 need a hint?
pyb-loop-list-items.py🔒 given lines are locked — write your code in between
loading...