A list in Python is like a row of numbered lockers, side by side, each one holding exactly one item. You open a locker by its number, not by guessing what's inside - and locker numbers always start counting from 0, not 1. So pets[0] opens the very first locker, and pets[1] opens the second one right next to it.
A list stores multiple values together in one ordered container, each one accessible by its position number (starting at 0, not 1). It's how you keep track of a whole collection of things instead of just a single value.
my_list = [item1, item2, item3]
my_list[0] # first item
len(my_list) # how many itemscolors = ["red", "green", "blue"]
print(colors[0])
print(colors[2])
print(len(colors))colors[0] is the FIRST item ('red'), because Python counts positions starting from 0. colors[2] is the third item ('blue'). len(colors) counts how many items are in the list altogether - 3.
colors = ["red", "green", "blue"]
print(colors[-1])Negative indices count backward from the end of a list, the same rule that applies to text: colors[-1] is always the LAST item, no matter how long the list is, without needing to know its exact length.
Mistake 1: assuming the first item is at position 1 - it's actually at position 0, so colors[1] is the SECOND item, not the first. Mistake 2: asking for a position that doesn't exist - a 3-item list only has positions 0, 1, 2, so colors[3] crashes with IndexError: list index out of range, since there's no fourth locker. Mistake 3: assuming copying a list with list2 = list1 makes an independent second list - it actually makes list2 point at the SAME list, so changing list2 (like list2.append(...)) changes list1 too; use list1.copy() or list(list1) to make a real, separate copy.
In the app this lesson continues with the animated explanation, spoken aloud, and then the practice: Print the second item in the list ("dog") instead of the first - remember locker numbers start at 0. The editor runs your child’s real code and checks the result, with their coding buddy reacting to what they wrote.
Try it free