Count, Collect, and Organize
Learn how to store, add to, and loop through lists.
Sometimes, we need to keep track of many values—like scores, names, or steps. Instead of using a new variable for each one, we can use a list to store them all together in a neat, single container.
They let us store and organize many values in one place, so our code can handle more with less effort.
Creating a list of values
A list is like a container that holds multiple items—such as numbers, words, or even other lists. We can create a list like this:
fruits = ["apple", "banana", "cherry"]print(fruits)
We just created our first list. A list holds a group of values in one variable.
Accessing specific items in a list
We can access items using their position (called an index). An index is the position number of an item in a list— it tells Python where to look.
In Python, indexing starts at 0, so the first item is at index ...