Parent guide · 5 min read
Python lists for kids: keeping many things in one variable
A variable in Python holds one thing, such as one name or one score. Real programs usually need many: all the scores in a game, every word in a sentence, a to-do list. A list is Python’s way of keeping many things in one place, in order. Most beginner trouble comes down to one surprise, that counting starts at 0, and two or three small slips around it. This guide explains the idea, traces an example line by line, and lists the errors to expect.

Try this tonight
5 things you can do at home
Make a real list on paper first
Write three favourite foods in a column and number the lines starting from 0. Then ask "what is at position 2?" Having done it once by hand, the 0-based counting stops being a rule to memorise and becomes a thing your child has already seen.
Type the smallest list and print it
Run fruits = ["apple", "banana", "cherry"] and then print(fruits), then print(fruits[0]) and print(len(fruits)). Predict each output before pressing run. Predicting first is the habit that makes lists click.
Change it and watch what happens
Add fruits.append("mango") and print the list again, then change one item with fruits[1] = "pear". A list can be changed after it is made, which is the main reason to use one rather than separate variables.
Walk through the list with a loop
Try for fruit in fruits: print(fruit). It prints each item in order without needing to know how many there are. If loops are new, do this step after the lists feel comfortable on their own.
Make the error on purpose
Print fruits[3] on a three-item list and read the message together: IndexError: list index out of range. Seeing the error once, with the cause known, takes the fear out of the next time it appears.
What a list is, and why it exists
If a program tracks five scores with five separate variables, adding a sixth means rewriting code. A list keeps them under one name: scores = [8, 5, 9]. The program can ask how many there are with len(scores), find the biggest with max(scores) and add more with append, without any new variable names.
The items sit in order and each has a position number, called an index. Text items go in quotes ("apple") and numbers do not (9). Items may be mixed in one list, but beginners get on best keeping to one kind per list.
Why counting starts at 0
The index says how far an item is from the start of the list. The first item is 0 steps from the start, the second is 1 step away and so on. A list of three items therefore has positions 0, 1 and 2, and there is no position 3. This is a convention across most programming languages, not something specific to Python.
Python also allows negative positions from the end: fruits[-1] is the last item, "cherry", whatever the length. It is handy but not needed on day one.
Worked example: tracing a list, line by line
Take scores = [8, 5, 9]. Then scores[0] is 8, scores[2] is 9, and len(scores) is 3. After scores.append(7), the list is [8, 5, 9, 7] and len(scores) is 4. After scores[1] = 6, it is [8, 6, 9, 7].
Now add up the items: 8 + 6 + 9 + 7 = 30, which is what sum(scores) gives. The largest is max(scores), 9. Tracing every line by hand like this, and only then running the code to compare, is the best check that a child understands, not just copies.
The errors beginners hit most
IndexError: list index out of range comes from asking for a position that is not there, nearly always from counting from 1. The last position is len(list) - 1. A near relative is using round brackets, fruits(0), which gives a different error, because brackets for positions are square.
The sneakiest is writing fruits = fruits.append("mango"). The append method changes the list in place and gives back nothing, so fruits becomes None and the list is gone. Write fruits.append("mango") on its own line. Forgetting the quotes round text gives a NameError, because Python thinks apple is a variable.
Signs it’s time for outside help
When home help has done what it can
- Keeps getting IndexError and cannot say why.
- Expects the first item to be at position 1.
- Makes a new variable for every item instead of using one list.
- Writes fruits = fruits.append(...) and is puzzled when the list disappears.
- Copies list code that works but cannot predict its output before running it.
Questions parents ask
FAQ
What is a list in Python?
A list is an ordered collection of items kept under one name, written inside square brackets and separated by commas, for example [8, 5, 9]. Items can be added, changed and removed after the list is made.
Why does Python start counting at 0?
The position is how far an item is from the start of the list, so the first item is 0 steps away. Most programming languages work this way. A list of three items has positions 0, 1 and 2.
How do I add something to a list?
Use append, for example fruits.append("mango"). It adds the item to the end. Do not write fruits = fruits.append("mango"), because append returns nothing and the variable would become None.
Does my child need loops before lists?
No. A child can create, print and change a list with only variables. Loops make lists far more useful, because a loop can visit every item, but the two can be learned in either order.
Further reading
Classes that fit
Live, 50–60 minutes, four learners at most or 1-on-1.
Not sure which is right for your child?
Tell us their age and what they have tried so far, and we will suggest where to start before you book anything.

