Loading ARcademy...
0 of 57 lessons completed
A variable usually stores a single value. But what if you need to store several values together, such as the names of students, a list of products, or your favorite colors?
This is where lists are useful.
A list is a collection of items stored in a single variable. Lists keep items in order, and each item has its own position called an index.
Create a list using square brackets [] and separate the items with commas.
colors = ["Red", "Blue", "Green"]
This list contains three items:
RedBlueGreenPython uses zero-based indexing, which means the first item is at index 0, not 1.
print(colors[0])
print(colors[2])
Red
Green
Here's how the indexes work:
Index: 0 1 2
Red Blue Green
So:
colors[0] → Redcolors[1] → Bluecolors[2] → Green💡 Remember: The first item in a Python list is always at index
0.