Python for non-programmers Ep. 4
Lists and tuples in Python: differences, methods, and practical examples
Hi there, and welcome to Episode 4 of this amazing journey with Python — the tool I aim to teach to “non-programmers” like me!
Let’s dive directly into today’s topic 🔻
When you start programming, single variables like x = 5 or name = “Alice” work fine.
But as your data grows — more names, more numbers, more complexity — you need something smarter.
That’s when lists and tuples come to the rescue. 🚀
Think of them as containers: both can hold multiple values, but they behave quite differently.
📦 Lists — Your Flexible Box of Data
A list is like a box you can open, rearrange, and fill as you wish.
You create one using square brackets [], separating each element with a comma.
shopping_list = [”apples”, “bread”, “milk”]
print(shopping_list[0]) # Output: applesLists can store anything — strings, numbers, even other lists.
mixed = [”Alice”, 25, True, [1, 2, 3]]✏️ Lists Are Mutable
That means you can change them after creation:
shopping_list.append(”eggs”) # Add a new item
shopping_list.remove(”bread”) # Remove an item
shopping_list[0] = “oranges” # Replace an elementThis flexibility makes lists perfect for data that evolves — your to-do list, your favorite songs, or daily expenses. 🎧💰
⚙️ Methods: The Built-in Tools of a List
Maybe in the short script I’ve pasted before you noticed something new after the name of the property. That thing is a method.
A method is like a special action you can perform on an object.
You “call” a method by writing a dot after your list’s name — for example:
my_list.method_name()Here are some of the most useful list methods you’ll use often:
numbers = [3, 1, 4]
numbers.append(9) # ➕ Adds 9 at the end → [3, 1, 4, 9]
numbers.sort() # 🔢 Sorts the list → [1, 3, 4, 9]
numbers.reverse() # 🔄 Reverses the order → [9, 4, 3, 1]
numbers.pop() # 🗑️ Removes and returns last item → [9, 4, 3]
numbers.count(3) # 🔍 Counts how many 3s → 1
numbers.index(4) # 📍 Finds position of 4 → 1Each method is a built-in mini function designed specifically for lists —they save time, make your code cleaner, and are easy to remember.
Any variable in Python has its own set of methods; we’ll discover more of them in the following chapters…
📍 Tuples — The Locked Box
A tuple looks a lot like a list, but with one big difference:
It can’t be changed once created.
You create a tuple using round brackets () and separate elements with commas:
coordinates = (45.5, 9.2)
print(coordinates[0]) # Output: 45.5Tuples are immutable, meaning you can’t add, remove, or modify items.
This might sound limiting, but it’s actually useful when you want your data to stay safe and consistent.
📌 Example:
Coordinates
(x, y)Birth dates
(day, month, year)RGB colors
(255, 0, 0)
These values shouldn’t change — that’s why tuples are perfect for them.
🧰 Tuple Methods (A Short List)
Since tuples are immutable, they have fewer methods than lists.
Here are the two main ones you’ll actually use:
numbers = (3, 1, 4, 1)
numbers.count(1) # 🔍 Counts how many times 1 appears → 2
numbers.index(4) # 📍 Finds position of 4 → 2That’s it — simple and stable. Tuples are all about reliability, not flexibility.
🧪 Practice Time: Build It Yourself
Try creating the following in your Python notebook:
A list of your top 3 favorite movies 🎬
Add a new movie using
.append()Remove one using
.remove()Then print the list again to see the changes.
Now create a tuple of your birth coordinates (latitude, longitude) and try modifying one value — notice what happens. 😉
💭 Why This Matters
Learning lists and tuples gives you the foundation to handle any kind of data.
Lists are perfect when your data evolves.
Tuples are ideal when your data must stay locked.
Once you master both, you’ll start writing cleaner, more intentional Python code. 🧠✨
🚀 Coming Next
In the next episode, we’ll explore dictionaries — Python’s way to store data in key-value pairs, just like a digital phonebook.
Get ready to make your code even more organized and readable!
Keep coding, keep learning, and see you in the next episode! 🐍


