LESSON 8

Lists

Learning objective: Store ordered collections in lists.

Understand

Lists hold multiple items in order.

A Python list is written with square brackets. Items have an index starting at 0. You can add with append(), remove items, and loop over them. Lists are one of Python's most-used types.

Analogy: A list is like a numbered shopping list you can add to and cross off.

See It in Action

Creating and using a list:

fruits = ["apple", "pear"]
fruits.append("mango")
print(fruits[0])   # apple
How it works: append adds an item to the end, and fruits[0] reads the first item by index.

Try It Yourself

  1. Create a list of three items.
  2. Append a fourth item.
  3. Loop over the list and print each.

Quick Quiz

What index is the first list item?

Challenge

Build a list of tasks, add one, then print them all.

Success condition: Your list grows and prints every item.