Lists are one of the most important features in Python. They let us store multiple bits of information together in one tidy container. Instead of creating a new variable for each item, you can bundle them up into a single list.
Think of a shopping list: instead of writing “milk = …, bread = …, eggs = …”, you can keep everything together.
shopping = ["milk", "bread", "eggs"]
print(shopping)
This prints:
['milk', 'bread', 'eggs']
The square brackets tell us it’s a list, and the items inside are separated by commas.
Accessing Items by Index
Every item in a list has a position number, known as an index. Python starts counting from zero (which can feel odd at first!).
shopping = ["milk", "bread", "eggs"]
print(shopping[0]) # milk
print(shopping[1]) # bread
print(shopping[2]) # eggs
This is how you grab individual items from a list.
Things to try:
- Make a list of your top three films. Print only the second one using its index.
- Try printing the last item in a list by using its index.
Adding Things to a List
Lists aren’t fixed — you can add to them whenever you like. The simplest way is with append(), which puts a new item at the end.
shopping = ["milk", "bread", "eggs"]
shopping.append("biscuits")
print(shopping)
Now biscuits are safely added to the list.
If you want to insert something at a specific position, use insert(index, item).
shopping.insert(1, "butter")
print(shopping)
Here, butter goes in at position 1, pushing the other items along.
Things to try:
- Start with a list of three colours and add a fourth using
append(). - Use
insert()to put something at the start of the list.
Modifying Items in a List
Sometimes you don’t want to add or remove something, you just want to change it. To do this, you can use the index directly.
shopping = ["milk", "bread", "eggs"]
shopping[1] = "butter"
print(shopping)
Now bread has been replaced by butter. Simple!
Things to try:
- Create a list of three animals, then change the second one to a different animal.
- Make a list of numbers and replace the first number with a larger one.
Removing Things from a List
There are a few ways to take things out of a list:
- By name with
remove()
shopping = ["milk", "bread", "eggs", "biscuits"]
shopping.remove("biscuits")
print(shopping)
- By position with
pop(index)
shopping = ["milk", "bread", "eggs"]
shopping.pop(1)
print(shopping)
This removes the item at position 1 (bread).
- Without giving an index,
pop()just removes the last item
shopping = ["milk", "bread", "eggs"]
shopping.pop()
print(shopping)
Eggs disappear here because they were last in the list.
Things to try:
- Make a list of four sports and remove one by name.
- Use
pop()to delete the item at index 0. - Create a list of three snacks and remove the last one using
pop()with no index.
Wrapping Up
Lists are like the backbone of Python programming. They let you group items together, add new ones, update them, or remove them when they’re no longer needed. Once you’ve got the hang of indexes and the basic list functions, you’ll be able to manage information much more easily.





