Throughout Part 3 so far, we’ve focused on the list, Python’s workhorse for storing collections of data. We’ve emphasized that lists are mutable, meaning they are designed to be changed (a concept we covered in Post #49). But what if you have a collection of items that you want to ensure never changes after it’s created?
For this, Python gives us an immutable counterpart to the list: the tuple.
In this post, you’ll be introduced to tuples, learn their key properties, and understand why you might choose to use an unchangeable collection over a changeable one.
What is a Tuple?
A tuple (pronounced ‘tupple’ like couple, or ‘toople’) is an ordered, immutable collection of items.
Let’s break that down:
- Ordered: Just like a list, the items in a tuple have a defined position, and that order is preserved.
- Immutable: This is the key difference. Once a tuple is created, its contents cannot be altered. You cannot add new items, remove items, or change any of the existing items.
A good analogy: a list is like a to-do list written on a whiteboard, which you can erase and update. A tuple is like a sentence carved in stone—it’s permanent.
Creating and Using Tuples
You create a tuple by placing items inside parentheses ()
, separated by commas.
# A tuple representing a coordinate
point = (10, 20)
# A tuple of strings
weekdays = ("Monday", "Tuesday", "Wednesday")
print(point)
print(weekdays)
In many ways, you can use tuples just like you use lists, as long as you’re not trying to change them.
Accessing Items
Indexing and slicing work exactly the same as they do with lists (which we learned in Post #47 and Post #48).
point = (10, 20, 30)
print(f"The first element is: {point[0]}")
print(f"The last element is: {point[-1]}")
print(f"A slice of the tuple: {point[0:2]}")
Looping
You can loop through a tuple with a for
loop, just like a list.
weekdays = ("Monday", "Tuesday", "Wednesday")
for day in weekdays:
print(day)
The Proof of Immutability
Here is where tuples and lists truly diverge. If you try to change an item in a tuple after it’s created, Python will stop you with an error.
point = (10, 20, 30)
# This will cause a TypeError!
# point[0] = 5
Running this code will crash your program with TypeError: 'tuple' object does not support item assignment
. This is Python protecting you from changing data that is meant to be constant.
Similarly, tuples do not have methods like .append()
, .remove()
, .sort()
, or .reverse()
because all of those methods would modify the tuple in-place, which is not allowed.
Why Use a Tuple Instead of a List?
If lists are so much more flexible, why would you ever use a tuple?
- Data Integrity: The primary reason is to guarantee that a piece of data remains constant. If you have a collection of values that represents a single, fixed entity—like an (x, y) coordinate, an RGB color value
(255, 0, 0)
, or a person’s date of birth—storing it in a tuple ensures that it cannot be accidentally changed elsewhere in your program. - Performance: As a minor benefit, because tuples are simpler than lists, Python can create and process them slightly faster. This is a micro-optimization, but it can be relevant in performance-critical applications.
- Dictionary Keys (Advanced): As a sneak peek for a future topic, only immutable types can be used as keys in a dictionary. This makes tuples suitable for this role, while lists are not.
What’s Next?
You’ve now met the tuple: an ordered, immutable collection that is perfect for storing data that shouldn’t change. It’s like a “read-only” version of a list.
Creating a tuple with multiple items is straightforward, but what about a tuple with only one item? There’s a small but critical piece of syntax you need to know, which often surprises beginners. In Post #59, we will look at this specific syntax rule for creating tuples.
Author

Experienced Cloud & DevOps Engineer with hands-on experience in AWS, GCP, Terraform, Ansible, ELK, Docker, Git, GitLab, Python, PowerShell, Shell, and theoretical knowledge on Azure, Kubernetes & Jenkins. In my free time, I write blogs on ckdbtech.com