Learn

Lists order items so that they’re in a specific sequence. For example the comic strip, as a list, stores frames in a specific order. Without an order, the story wouldn’t make sense!

Lists sequences tell us that each value has a specific position in the list. The position of a value in a list is known as its index. We can think of an index as an address - it’s what we use to locate an item in a list.

List indices (the plural of index) are numbers. Usually, lists start their indices at 0 and then add one for each value. So if we want to select the first item in the list, we would use 0 to do so! The second item would be at index 1, and so on.

Knowing an item’s index allows us to select a value from a list and do something with it, like save it to a variable. It can also be useful in modifying a list, whether by replacing, adding, or removing something.

Let’s practice modifying values in a list.

### Instructions

For this exercise, we will have to assign colors to certain list indices. Use the `Set index to` command to make the left list match the right list.

Hint
The first (index 0) and last (index 3) elements need to be changed to match the colors on the right-hand side.
Solution
``````Set 0 to blue
Set 3 to red``````