Arrays and indexes
About this lesson: Arrays and indexes
In short
An array stores a set of related values under one name. Each item has an index, starting at 0. Move the slider to read different items.

What you'll explore
- Index: Pick one item
- An array stores a set of related values under one name. Each item has an index, starting at 0. Move the slider to read different items.
- Loop over an array: Visit every item
- A loop with an index can visit every item. Here it adds all the scores. Step through and watch i and total.
- Why arrays?: One name instead of many
- Compare five separate variables with one array. Which is easier to loop over and extend?
- Check yourself: Index
- colours = ["red", "green", "blue", "pink"]
Also in this lesson
- Common mix-ups
- Using arrays
- Egg-box array
Words to know
- array
- A collection of values stored under one name.
- index
- The position number of an item, starting at 0.
- element
- One item in an array.
- list
- Python's name for an array.
- len
- A function giving the number of items.
Sources
- BBC Bitesize KS3 Computer Science
- Raspberry Pi Foundation, Computing curriculum resources