I recently shared what I learned about lists, and while I was getting comfortable with them, I came across tuples. They just looked like lists with different brackets, they felt unnecessary… but I was wrong 😅
👉 You can read my post on lists here: [https://dev.to/stillpurrfect/python-lists-one-of-the-first-things-that-actually-made-sense-k1p]
What I thought at first
I was mostly using lists like this:
numbers = [1, 2, 3]
Then I saw tuples:
numbers = (1, 2, 3)
And I was like… okay? What’s the difference?
What I later realized
The main difference is simple:
👉 You can change a list
👉 You can’t change a tuple
That’s it.
At first, that felt like a disadvantage.
But then I started thinking about it differently.
A small example
Let’s say I have coordinates:
coordinates = (10.5, 20.3)
These values are not supposed to change.
So using a tuple actually makes sense here.
It’s like saying:
“This is fixed.”
Something I didn’t expect
Functions can return tuples without you even noticing:
def get_user():
return "Maryanne", 21
name, age = get_user()
When I first saw this, I didn’t even know that was a tuple 😅
My takeaway (so far)
I’m still learning, but this is how I see it now:
- Use a list when things might change
- Use a tuple when things should stay the same It’s a small thing, but it actually makes your code clearer.
Final thought
I used to think tuples were unnecessary.
Now I see them as a simple way to be more intentional with my code.
Still learning, but I thought I’d share this in case someone else is confused like I was.
If you’re also learning Python, did tuples make sense to you immediately, or did they confuse you at first?
I’m still building on the basics step by step next I might dive into dictionaries. If you're learning too, we’re in this together.
Top comments (0)