The dragon explains
Lists and indexing
The dragon: A list holds several things in ONE box, in order. Square brackets, commas between items.
The dragon: hoard = ["gold", "gems", "a sword"] makes a list of three things. To get ONE item back, use its INDEX.
example.pyPython 3hoard = ["gold", "gems", "a sword"]print(hoard[0])
OutputgoldThe dragon: Same rule as range(): the FIRST item is index 0, not 1. hoard[1] is the SECOND item.
example.pyPython 3hoard = ["gold", "gems", "a sword"]print(hoard[1])
OutputgemsThe dragon: Negative indexes count from the END. hoard[-1] is always the LAST item, whatever the list's length.
example.pyPython 3hoard = ["gold", "gems", "a sword"]print(hoard[-1])
Outputa swordThe dragon: Watch the boundary: a 3-item list has valid indexes 0, 1, 2 — never 3. Asking for hoard[3] is one too far.
Quick check
Check your understanding
Say your answer out loud before reading the marked one. Every wrong option is a mistake real beginners make.
Question 1 of 2
party = ["Ember", "Blaze", "Frost"]. What does party[1] give you?
question.pyPython 3party = ["Ember", "Blaze", "Frost"]print(party[1])
- BlazeCorrect
- 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.
Question 2 of 2
party has 5 names. Which index ALWAYS gets the last one, no matter how many names are in the list?
- party[-1]Correct
- 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.
In the game
What you'll practice
Four levels in the game: one guided first try with the shape of the answer already there, then three to solve on your own.
- 1
GuidedYour first try
The dragon's hoard is a list: ["gold", "gems", "a sword"]. Print the FIRST item — remember, the first item is index 0, not 1.
- +3
PracticeThree more, on your own
This lesson is part of PRO.
PRO is a one-time $49.99 purchase, no subscription, and unlocks this whole topic along with everything else. Topics 1–3 are free, start to finish.
Unlock this lesson with PROStuck three times? The game offers the answer — unasked.