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
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.)
Press Next to run one line at a time, and check each prediction against the Output box.
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
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?
What's the pattern for creating a list in Python?
Which list items need quotation marks?
What is an index?
What index does the first item in a Python list have?
A list holds 7 items. What is the index of the last one?
How do you display the item at index 4 of a list called days?
What happens if you use an index where the list holds no item?
Can an index be a calculation, like days[day - 1]?
Someone types 3, meaning the 3rd item. What index do you use?
How can selection be used with a list?
Why is a list called a dynamic data structure?
What does days.append("Funday") do?
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 postedMore KS3 Computer Science topics
- Abstraction in computational thinking
- Adding binary numbers
- Binary to denary conversion
- Boolean logic: AND, OR, NOT
- Bubble sort
- Building truth tables
- Client-server vs peer-to-peer
- Collecting and recording data
- Comparing sorting algorithms
- Compressing data
- Creating a 3D animation
- Decomposition: splitting problems up
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.