Python: lists

A list stores many values under one name. Instead of 30 variables for 30 test scores, you need just one list.

Practise this lesson free (6 questions)

More tools

Making and indexing a list

pets = ["cat", "dog", "fish"]
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 = ["cat", "dog", "fish"]
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

scores = [4, 7, 2, 9]
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.
Worked example

What does this print?
pets = ["cat", "dog", "fish"]
pets.append("rabbit")
print(len(pets))
print(pets[3])

  1. After append, the list is cat, dog, fish, rabbit: 4 items.
  2. Index 3 is the fourth item: rabbit.

Answer: 4 then rabbit

Key idea

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.

Key words
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.

All KS3 Computing key terms and definitions →

Common mistakes
Quick check

Try two quick questions

See if it has sunk in. Answers are marked straight away.

Extra practice

2 more questions

Try each one, then tap to check.

  1. 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.

  2. 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.

Video for this lesson coming soon. Subscribe on YouTube

Sources and references

Facts checked against the sources below, 27 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.

Related lessons