Python for Beginners
Guided lesson · 10 minutes

4. Repeat work with loops and lists

Work through the guide, keep private notes, and mark this lesson complete when you’re ready.

01

Repeat an action

A for loop repeats an instruction for each item in a sequence. A list stores an ordered set of values such as task names. Use a loop variable that makes the current item clear.

02

Avoid changing the wrong thing

The body of a loop is controlled by indentation. Check whether a calculation should happen once after the loop or once for every item. Test with an empty list and a list containing one item to find common edge cases.

03

Try it

Create a list of three course topics and print each one with a loop. Then add an item and verify it appears without writing another print statement.

Key takeaways

  • Lists keep ordered values.
  • Loops apply work to each item.
  • Test empty and one-item cases.
Enroll in this course to save lesson progress.View course