๐ก Interactive lessons ยท free, no sign-up
Python lists, and the index that starts at 0
Play Python Lists and Indexes
Loading Python Lists and Indexesโฆ
How to play Python Lists and Indexes
- Read the first step: a list is a row of boxes, each with an index.
- Move the sliders and switches to change the diagram and watch what happens. The readout under the picture shows the numbers.
- Answer each question. If you are wrong you get a hint and can try again, with no penalty.
- Some steps ask you to make something happen, such as hitting a target value. Experiment until it works.
- Finish the lesson to earn XP and see how many questions you got right first time.
Tips and strategy
- Do not rush. The controls are there to be played with, so try extreme values as well as sensible ones.
- Say what you notice out loud or write it down before you press Continue.
- Use the hint when you are stuck, and then try to explain the answer in your own words.
- Count from 0, and remember the last index is one less than the length.
Keep playing
More games you might like
Coding games ยท Ages 9+NewPython Practice LabWrite real beginner Python, run it in the browser and solve small challenges.
Pythonvariables
Play
Coding games ยท Ages 10+NewPredict the OutputRead a short Python program and choose what it prints. Then watch it run for real.
reading codePython
Play
Interactive lessons ยท Ages 10+NewPython For Loops and range()Change start, stop and step to see which numbers a loop uses.
Pythonfor loops
Play
Coding games ยท Ages 7+NewCode the RobotPlan a short command sequence to guide a robot through a grid maze.
sequencedebugging
Play
FAQ
Python Lists and Indexes: questions
Why does a Python list start at index 0?
Python counts how far an item is from the start, so the first item is 0 steps away. Most programming languages do the same.
What does a negative index do?
It counts from the end of the list: -1 is the last item, -2 is the one before it.
What causes an IndexError?
Asking for an index outside the list, such as index 5 in a list of 5 items (valid indexes are 0 to 4).
What age is this lesson for?
It suits ages 10 to 16 as a first step in Python.
Start a conversation
Questions about classes?
A parent or guardian can share the learner's age, level and goals, and we'll suggest a starting point and confirm the format before anything is booked.
- Tell us the learnerโs age or grade and goals
- Weโll suggest a suitable class or learning path
- Weโll confirm format, timing and fees with a parent or guardian