What Is a List? (And Why You'll Use It Everywhere)
The problem...
You have five soldiers. Each one has a name.
You could store them like this:
soldier1 = "Raven"
soldier2 = "Wolf"
soldier3 = "Ghost"
soldier4 = "Viper"
soldier5 = "Bull"
But what happens when you have fifty? Or five hundred?
One variable per value doesn't scale. It breaks.
The idea!
Python gives you a way to store multiple values in a single variable.
It's called a list.
One name. All the values. In order.
Making it real
Think of it like a numbered roster. Every entry has a position.
The roster has a name. The entries sit inside it, separated by commas, wrapped in square brackets.
In practice
soldiers = ["Raven", "Wolf", "Ghost", "Viper", "Bull"]
print(soldiers)
Output → ['Raven', 'Wolf', 'Ghost', 'Viper', 'Bull']
That's a list. Five values. One variable.
The full picture
A list can hold any type of value — strings, integers, floats, even a mix.
names = ["Raven", "Wolf", "Ghost"]
scores = [98, 74, 85]
mixed = ["Raven", 98, True, 3.14]
It can also be empty — a list waiting to be filled.
squad = []
Going further
Lists are ordered. The order you put values in is the order Python keeps them.
Lists are mutable. You can change them after you create them — add, remove, update.
Lists allow duplicates. The same value can appear more than once.
status = ["active", "active", "inactive", "active"]
What's really happening
Python creates a container in memory. Each value gets a position — a number, starting at 0.
The variable name points to the whole container. You get all the values at once, or you can reach any single one.
You'll see how to do that in the next lesson.
Heads up!
- Square brackets create a list — don't confuse them with parentheses or curly braces
- An empty list is still a list —
[]is valid - The values inside a list are called elements or items
- Lists can hold mixed types, but in practice you'll usually store one type per list
The mindset shift
Stop thinking: "I need a variable for each value."
Start thinking: "I need one variable that holds all the values."
What you should understand now
- A list stores multiple values in a single variable
- Values sit inside square brackets, separated by commas
- Lists are ordered, mutable, and allow duplicates
- A list can hold any type — strings, integers, floats, mixed
- An empty list is valid and useful