Python: lists
A list stores many values under one name. Instead of 30 variables for 30 test scores, you need just one list.
Making and indexing a list
print(pets[0])
print(pets[2])
print(len(pets))
Output:
cat
fish
3
Each item has an index (position). Python counts from 0, so pets[0] is the first item.
len() gives the number of items.
Changing a list
pets.append("rabbit")
print(len(pets))
print(pets[3])
Output:
4
rabbit
append adds an item to the end. You can replace an item by its index:
scores = [4, 7, 2, 9]
scores[1] = 10
print(scores)
prints [4, 10, 2, 9].
Looping through a list
total = 0
for s in scores:
total = total + s
print(total)
The loop visits each item in turn, adding it to total: 4 + 7 + 2 + 9 = 22.
Lists are a kind of data structure. Other data structures include tables (rows and columns) and arrays.
What does this print?
pets = ["cat", "dog", "fish"]
pets.append("rabbit")
print(len(pets))
print(pets[3])
- After append, the list is cat, dog, fish, rabbit: 4 items.
- Index 3 is the fourth item: rabbit.
Answer: 4 then rabbit
A list holds many items under one name. Indexes start at 0. len() counts items, append adds to the end, and a for loop can visit every item.
- List
- A data structure that stores many items under one name, in order, such as scores = [4, 7, 2].
- AND
- A Boolean operator that gives True (1) only when both inputs are True.
- For loop
- A count-controlled loop that repeats a set number of times.
- Output
- Information sent out from a computer, for example to a screen, speaker or printer.
- Not “fruit[0] = "pear"”. This replaces the first item instead of adding one.
Try two quick questions
See if it has sunk in. Answers are marked straight away.
2 more questions
Try each one, then tap to check.
What does this print?
colours = ["red", "blue", "green"]
print(colours[2])Show the answer
Answer: green
Indexes start at 0, so colours[2] is the third item: green.
What does this print?
fruit = ["apple", "pear", "plum", "fig", "kiwi", "lime"]
print(len(fruit))Show the answer
Answer: 6
len counts the items: 6.
Check you have got it
Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.
Facts checked against the sources below, 27 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.