KS3 · Computer Science

Working with lists in Python

Seven days could mean seven separate variables. A list keeps them under one name, in order — and you grab any day by its position, counting from 0.

Computing · Programming

Seven days, one list

A list is a data structure: one name holding lots of related items, one after another, in order. (Tables and arrays are other data structures — this lesson is all about lists.) Beside the code, the list is drawn as numbered slots. Step through the program and watch which slot each index lands on.

Before you press Next, make a prediction: what will print(days[1]) show?

1 days = ["Monday", "Tuesday",
2 "Wednesday", "Thursday",
3 "Friday", "Saturday",
4 "Sunday"]
5 print(days[1])
6 print(days[4])
7 day = int(input("Day number (1-7): "))
8 print(days[day - 1])
9 print(days[7])

Variables

days[0]="Monday"days[1]="Tuesday"days[2]="Wednesday"days[3]="Thursday"days[4]="Friday"days[5]="Saturday"days[6]="Sunday"

Output

 

Step 1: One name, seven items. Python numbers the slots as it fills them: "Monday" goes into slot 0 and "Sunday" ends up in slot 6. Seven items, numbered 0 to 6. (The list is split over four lines only to keep it readable — it's still one list.)

1 / 6

Press Next to run one line at a time, and check each prediction against the Output box.

Step 1 of 6: One name, seven items. Python numbers the slots as it fills them: "Monday" goes into slot 0 and "Sunday" ends up in slot 6. Seven items, numbered 0 to 6. (The list is split over four lines only to keep it readable — it's still one list.).

Check your thinking

Which snack is snacks[1]?

Here is a new list: snacks = ["crisps", "apple", "flapjack", "banana", "yoghurt"]

Which of these is closest to what you think right now?
How sure are you?

Your turn

Build two lists from scratch

Every Python list is built from the same pattern: the list's name (its identifier), then =, then the items inside square brackets with a comma between each one — like this: colours = ["red", "green", "blue"]. Items that are text (string literals) need quotation marks round them. A list that stores whole numbers (integers) doesn't need the quotation marks.

Write two lines of Python. Line 1 creates a list called pets that holds the text items cat, dog and rabbit. Line 2 creates a list called ages that holds the whole numbers 11, 12 and 14. [5 marks]

0 words · your answer stays on this page and is not sent anywhere.

Debug it

The playlist plays the wrong song

This program should ask for a track number from 1 to 5 and play that track. But typing 1 plays "Echo" (the second track), and typing 5 crashes with an IndexError. Which line is wrong?

A program with one bug — which line goes wrong?

Lists + selection

Finish the seasons program

This program asks for a month number (1 to 12), shows the month's short name, then shows its season. In this program, winter is months 12, 1 and 2; spring is 3 to 5; summer is 6 to 8; and autumn is 9 to 11. Choose the missing lines.

  1. months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]Twelve items, so the indexes run 0 to 11.
  2. seasons = ["winter", "spring", "summer", "autumn"]Four items: winter is at index 0 and autumn at index 3.
  3. month = int(input("Month number (1-12): "))
  4. missing step
Which line is step 4?

Predict, then check

Think back to the program that crashed on days[7].

days holds seven items, so its indexes run 0 to 6 — that's why days[7] crashed. Now this line runs: days.append("Funday"). What happens?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

One name, lots of items — and the first one lives at index 0.

What you need to know

  • A list is a data structure: it stores several related items under one name, in a particular order.
  • Create a list with a name, then =, then the items inside square brackets, separated by commas. Text items need quotation marks; integers don't.
  • Every item has an index (its position). Indexing starts at 0, so the first item is at index 0.
  • Access an item with its index in square brackets, e.g. print(days[4]). An index with no item there gives an IndexError.
  • An index can be an expression that works out to an integer, e.g. days[day - 1].
  • Selection (if / elif / else) can display a different list item on each path, and a list can grow or shrink as items are added or removed.

The big picture

A list is a data structure: one name holding many related items, in order. Create it with a name, =, and the items in square brackets separated by commas — quotation marks round text, none round integers. Indexing starts at 0, so days[1] is the second item; an index can be any expression that gives an integer, like days[day - 1], and an index with no item gives an IndexError. Selection can show a different item on each path, and a list can grow or shrink.

Key points

1A list holds many related items under one name, in the order you wrote them.
2Syntax: name = [item, item, item] — quotation marks round text, none round integers.
3The first item is at index 0; in a list of seven items the last index is 6.
4days[7] in a seven-item list is an IndexError — there's no item there.
5To turn a person's count (from 1) into an index, subtract 1: days[day - 1].
6A list is dynamic: it grows when you add items and shrinks when you remove them.

Worked example

Problem

A game stores four high scores: scores = [12, 7, 15, 9]. Then the program runs n = 3. What does each line display? (a) print(scores[1]) (b) print(scores[n - 1]) (c) print(scores[4])

⚠ Watch out

Counting the first item as position 1. In Python the first item is at index 0, so days[1] is Tuesday, not Monday — and in a seven-item list, days[7] doesn't exist, so it gives an IndexError.

🧠

Memory hook

An index counts steps from the start. The first item is zero steps away, so it's at index 0.

✓

Check yourself

Without looking back: pets = ["cat", "dog", "rabbit", "hamster"]. What does print(pets[3]) display, which index holds "cat", and what would print(pets[4]) do?

Flashcards

(13)
What is a list?
A data structure that stores several related items under one name, one after another in a particular order.
What's the pattern for creating a list in Python?
The list's name, then =, then the items inside square brackets with commas between them, e.g. days = ["Monday", "Tuesday", "Wednesday"].
Which list items need quotation marks?
Text items (string literals) do, e.g. "cat". Integers don't, e.g. [11, 12, 14].
What is an index?
The position number of an item in a list — where the item is stored.
What index does the first item in a Python list have?
0 — indexing in Python is zero-based.
A list holds 7 items. What is the index of the last one?
6 (the indexes run 0 to 6).
How do you display the item at index 4 of a list called days?
print(days[4]) — the index goes inside square brackets after the list's name.
What happens if you use an index where the list holds no item?
Python raises an IndexError and the program stops.
Can an index be a calculation, like days[day - 1]?
Yes — any expression works, as long as it works out to an integer.
Someone types 3, meaning the 3rd item. What index do you use?
2 — subtract 1 from their count, e.g. days[day - 1].
How can selection be used with a list?
An if / elif / else statement checks conditions to choose a path, and each path can display a different item from the list.
Why is a list called a dynamic data structure?
It can grow or shrink as you add or remove items.
What does days.append("Funday") do?
Adds "Funday" as a new item at the end of days, so the list grows by one.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More KS3 Computer Science topics

See the full KS3 Computer Science curriculum →

How this lesson was checked. This KS3 Computer Sciencelesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 2 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.