CurriculumPython Lists, Indexing and Slicing for KidsLists and indexing

Python Lists and Indexing from Zero, Explained

A row of things, and how to pick out one item at a time.

Lesson 1 of 5PROAges 10+
See what PRO unlocks →

Lists and indexing

A list holds several things in ONE box, in order. Square brackets, commas between items.

hoard = ["gold", "gems", "a sword"] makes a list of three things. To get ONE item back, use its INDEX.

hoard = ["gold", "gems", "a sword"]
print(hoard[0])

Output

gold

Same rule as range(): the FIRST item is index 0, not 1. hoard[1] is the SECOND item.

hoard = ["gold", "gems", "a sword"]
print(hoard[1])

Output

gems

Negative indexes count from the END. hoard[-1] is always the LAST item, whatever the list's length.

hoard = ["gold", "gems", "a sword"]
print(hoard[-1])

Output

a sword

Watch the boundary: a 3-item list has valid indexes 0, 1, 2 — never 3. Asking for hoard[3] is one too far.

Check your understanding

party = ["Ember", "Blaze", "Frost"]. What does party[1] give you?

party = ["Ember", "Blaze", "Frost"]
print(party[1])
  • Blaze
  • Ember
  • Frost

Why: Indexing starts at 0: party[0] is Ember, party[1] is Blaze, party[2] is Frost. The index is always one less than the item's position when you count normally.

party has 5 names. Which index ALWAYS gets the last one, no matter how many names are in the list?

  • party[-1]
  • party[5]
  • party[4]

Why: party[-1] always means the last item, regardless of length — that's the whole point of negative indexing. party[4] happens to also work for a 5-item list specifically, but breaks the moment the list's length changes.

What you'll practice

The dragon's hoard is a list: ["gold", "gems", "a sword"]. Print the FIRST item — remember, the first item is index 0, not 1.

Unlock this lesson with PRO →

More from this topic

Lists and indexing is one lesson inside Python Lists, Indexing and Slicing for Kids — see the full lesson order and what the whole topic covers.

View the full topic →