Guided Notes

Loops

for loops, range(), while loops, break/continue, and list comprehensions.

for loops

Slide 1 / 5

planets = ['Mercury', 'Venus', 'Earth', 'Mars'] for planet in planets: print(planet)

A for loop runs its indented body once per item, with the loop variable (planet) holding the current item.

You can loop over any sequence — lists, tuples, and even strings: for char in "HELLO": visits one letter at a time.

← Control Flow