colors = ["red", "blue", "green"]Line-by-line explanation
- Square brackets begin and end the list.
- Commas separate its three string items.
colorsstores the entire list.
first = colors[0]Line-by-line explanation
colorsis the list.[0]asks for its first item.firststoresred.
some = colors[0:2]Line-by-line explanation
- The slice starts at index 0.
- It stops before index 2.
somestores red and blue.
Tiny Practice
Display the first fruit.
Starter template
fruits = ["apple", "pear"]
print(CHANGE_ME)Line-by-line explanation
- The list has two items.
- The first item has index 0.
Hint
- Use the list name.
- Add square brackets.
- Put 0 inside them.
Show Solution
fruits = ["apple", "pear"]
print(fruits[0])Line-by-line explanation
- The list is stored.
fruits[0]reads apple.- Print displays apple.