Single values only get you so far. Real programs deal with groups of things — a list of names, a set of scores, a lookup table of prices. Python gives you three main containers for this, and honestly, figuring out which one to reach for is half the battle when you're starting out.
Lists: the one you'll use most
fruits = ["apple", "banana", "cherry"]
fruits.append("date")
print(fruits[0]) # apple
print(fruits[-1]) # dateA list is an ordered, changeable collection. You can add to it, remove from it, sort it, loop through it — it does basically everything you would expect. Notice fruits[-1] grabs the last item without you needing to know how long the list is. Little touches like that are exactly why people enjoy writing Python.
Tuples: like a list, but locked
point = (3, 4)
x, y = point
print(x, y) # 3 4A tuple looks almost identical to a list but can't be changed once created. Why would you want that? Mostly to signal intent — if a set of values genuinely shouldn't change, like coordinates, using a tuple communicates that clearly, and it also happens to be a touch faster than a list. That second line, by the way, is called unpacking, and it's one of Python's nicer conveniences: pulling several values out of a tuple in one go.
Dictionaries: look things up by name, not position
person = {"name": "Ann", "age": 30}
print(person["name"]) # Ann
person["age"] = 31Instead of a numeric position, a dictionary looks values up by a key, the same way a real dictionary looks up a word to find its meaning. This is the container to reach for whenever "position one, two, three" doesn't make sense, but "give me the value for this name" does.
Looping through each of them
for fruit in fruits:
print(fruit)
for key, value in person.items():
print(key, "->", value)A quick way to decide which one to use
- Order matters and you might add or remove items — use a list.
- The values should never change once set — use a tuple.
- You need to look values up by a meaningful name instead of position — use a dictionary.
You genuinely won't go far wrong reaching for a list by default and switching to a dictionary the moment you catch yourself thinking "I wish I could look this up by name instead of counting positions." That instinct, once it clicks, basically never goes away.