The Problem with Variables
Variables are great for storing one thing.
name = "Sam"
But what if you want to invite 20 friends to a party? Use 20 variables?
friend1 = "Sam"
friend2 = "Alex"
friend3 = "Lee"
friend4 = "Kim"
# ... 16 more?! ๐ซ
Thatโs messy! There must be a better wayโฆ
Enter the List (The Treasure Chest) ๐ฆ

A List is a variable that can hold many things. It uses square brackets [].
friends = ["Sam", "Alex", "Lee", "Kim"]
Now we have one box (friends) containing four names!
Visual representation:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ friends LIST โ
โโโโโโโโฌโโโโโโโฌโโโโโโโฌโโโโโโโโโโโค
โ "Sam"โ"Alex"โ "Lee"โ "Kim" โ
โโโโโโโโผโโโโโโโผโโโโโโโผโโโโโโโโโโโค
โ [0] โ [1] โ [2] โ [3] โ
โโโโโโโโดโโโโโโโดโโโโโโโดโโโโโโโโโโโ
๐ฎ Real-World Connection
This is how Spotify stores your playlists! Your โFavoritesโ is a list of songs. Instagram has a list of your posts. Every game has a list of high scores. Lists are EVERYWHERE!
Finding Things in the Box (Indexing) ๐

How do we get โSamโ out of the box? We use the position number (index).
Important Rule: Computers start counting at 0. ๐คฏ
| โSamโ | โAlexโ | โLeeโ | โKimโ |
|---|---|---|---|
| 0 | 1 | 2 | 3 |
print(friends[0]) # Prints "Sam"
print(friends[2]) # Prints "Lee"
print(friends[3]) # Prints "Kim"
๐ Try This NOW!
What will this print?
colors = ["red", "blue", "green", "yellow"]
print(colors[1])
Click to check!
It prints "blue" because blue is at index 1! (Remember: we start counting from 0!)Why Start at 0?
Itโs a computer science tradition! Think of it like this:
- Index 0 = โzero steps from the startโ
- Index 1 = โone step from the startโ
- Index 2 = โtwo steps from the startโ
Once you get used to it, it makes sense! ๐
Making Changes ๐ง
Lists can change!
Adding Items
friends = ["Sam", "Alex"]
friends.append("Jo")
print(friends) # ["Sam", "Alex", "Jo"]
Changing Items
Oh no, โAlexโ canโt come. โMaxโ is coming instead.
friends = ["Sam", "Alex", "Lee"]
friends[1] = "Max"
print(friends) # ["Sam", "Max", "Lee"]
Removing Items
friends = ["Sam", "Alex", "Lee"]
friends.remove("Alex")
print(friends) # ["Sam", "Lee"]
Counting Items
How many friends do I have?
friends = ["Sam", "Alex", "Lee", "Kim"]
print(len(friends)) # 4
(len is short for โlengthโ)
Loops + Lists = Magic! โจ
Remember loops? They are BEST FRIENDS with lists!
friends = ["Sam", "Alex", "Lee", "Kim"]
for friend in friends:
print("Hello", friend + "!")
Output:
Hello Sam!
Hello Alex!
Hello Lee!
Hello Kim!
This is how Instagram shows you 100 photos. It just loops through a list!
Another Example: High Scores
scores = [100, 95, 87, 92, 88]
for score in scores:
print("Score:", score)
if score >= 90:
print(" Grade: A!")
else:
print(" Grade: B")
List Tricks ๐ฉ
Get the First and Last
fruits = ["apple", "banana", "cherry", "date"]
first = fruits[0] # "apple"
last = fruits[-1] # "date" (negative counts from end!)
Slice a List (Get a Part)
fruits = ["apple", "banana", "cherry", "date", "elderberry"]
middle = fruits[1:4] # Gets index 1, 2, 3 (not 4!)
print(middle) # ["banana", "cherry", "date"]
Check if Something is in the List
fruits = ["apple", "banana", "cherry"]
if "banana" in fruits:
print("Yes, we have bananas!")
Try It Yourself
Challenge 1: Make a list of your 3 favorite foods.
foods = ["pizza", "ice cream", "tacos"]
Challenge 2: Print the first one using index.
print(foods[0]) # pizza
Challenge 3: Add a 4th food to your list.
foods.append("cookies")
print(foods) # ["pizza", "ice cream", "tacos", "cookies"]
Challenge 4: Use a loop to print all your foods!
for food in foods:
print("I love", food)
Extra Challenge: The Todo List
Make a program that:
- Creates a list of 3 tasks
- Prints all tasks
- Asks which task is done (by index)
- Removes that task
- Shows remaining tasks
Solution:
tasks = ["Clean room", "Do homework", "Feed cat"]
print("Your tasks:")
for i in range(len(tasks)):
print(i, "-", tasks[i])
done = int(input("Which task is done? (enter number): "))
finished = tasks[done]
tasks.remove(finished)
print("\nRemaining tasks:")
for task in tasks:
print("-", task)
Common Mistakes & Fixes
โ Wrong: friends = ["Sam", "Alex"
Why it fails: Missing closing bracket!
โ
Right: friends = ["Sam", "Alex"]
Always close your brackets!
โ Wrong: print(friends[5])
Why it fails: If list has 3 items, index 5 doesn't exist!
โ
Right: print(friends[2])
Indexes go from 0 to (length - 1)
โ Wrong: friends.add("Jo")
Why it fails: The method is called .append(), not .add()
โ
Right: friends.append("Jo")
Remember: append, not add!
โ Wrong: friends(0)
Why it fails: Use square brackets, not parentheses!
โ
Right: friends[0]
Lists use [ ], functions use ( )
๐ Bug Hunter Betty Says:
โIf you see โIndexError: list index out of rangeโ, it means youโre trying to access an item that doesnโt exist! If your list has 3 items (indexes 0, 1, 2) and you try to access index 5, Python gets confused. Always check how long your list is with len()!โ
๐ Achievement Unlocked: List Collector! Wizard Level: Enchanter (8/10 complete)
๐ Todayโs Spell Book (Quick Reference)
# Create a list
my_list = ["apple", "banana", "cherry"]
# Access items (indexing starts at 0!)
first = my_list[0] # "apple"
last = my_list[-1] # "cherry" (from end)
# Modify list
my_list.append("date") # Add to end
my_list.remove("banana") # Remove specific item
my_list[0] = "apricot" # Change item at index 0
# Get info about list
length = len(my_list) # How many items?
if "apple" in my_list: # Is "apple" in the list?
print("Found it!")
# Loop through list
for item in my_list:
print(item)
# Useful list methods:
# .append(item) - add to end
# .remove(item) - remove specific item
# .sort() - sort alphabetically/numerically
# .reverse() - reverse the order
๐ก Parent/Teacher Tip
The โstarting at 0โ concept can be confusing! Try this: Line up 4 toys. Point to the first one and say โThis is zero steps from the start.โ Point to the second and say โThis is one step from the start.โ This physical demonstration often makes it click!
๐ Fun Fact
Lists can hold ANY type of dataโeven other lists! You can have a list of lists (like a grid for tic-tac-toe), or a list that mixes numbers and text: weird_list = [42, "hello", True, 3.14]. Python is very flexible!
In the next lesson, weโll learn about Functionsโhow to create your own custom commands!
This post is part of the Python Basics for Kids series, based on โPython for Kids from 8 to 88โ.