Member-only story
From One to Many
Collections of variables
In the last article, you set up your coding lab with VS Code. Before that, you learned about variables — the way computers remember single pieces of information.
But life rarely comes in singles.
- You don’t just have one expense — you have many.
- You don’t just store one ingredient — you store dozens.
- You don’t just watch one Netflix show — you watch a whole library.
To handle this, programming gives you collections of variables: structures that let you manage many values together.
Why Collections?
A single variable can store:
expense = 20But what if you have 10 expenses?
expense1 = 20
expense2 = 35
expense3 = 12
...This quickly becomes chaos. You need a way to group related values under one name. Collections solve this.
Types of Collections
1. Lists (or Arrays)
A list stores values in order.
expenses = [20, 35, 12, 50]
print(expenses[0]) # First expense: 20Think of it as a row of lockers, each numbered and holding a value.
2. Dictionaries (or Maps)
A dictionary stores key–value pairs.
cake = {…
