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 containing multiple items—such as numbers, words, or other lists. We can create a list like this:
Python
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 ...