A tuple is like a list, but unchangeable (immutable). It is written with round brackets: point = (3, 4).
Use tuples for fixed groups of values, like coordinates or RGB colours.
A one-item tuple needs a comma: ("a",)
Unpacking: x, y = point
Methods: count() and index().
💡 Key Takeaways: Python Tuples
Mastering Python Tuples helps you write clean and reliable Python code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
Python Tuples Code Example
Python
point = (3, 4)
x, y = point
print("x:", x, "y:", y)
rgb = (37, 99, 235)
print("Red value:", rgb[0])
try:
rgb[0] = 0
except TypeError as e:
print("Error:", e)
name, *scores = ("Ali", 80, 92, 75)
print(name, scores)
Free sign-in required · Google login available
Python Tuples Practice Exercises
Check what you learned in “Python Tuples”.
/ 3 solved
Fill in the blank
Create a tuple with one item.
single = ("a")
✓ Correct!Not quite. Try again.
Multiple choice
Can you change an item of a tuple after creating it?
✓ Correct!Not quite. Try again.
Code challenge
Unpack the tuple into x and y and print x + y.
Write the code in the live editor. Your answer is checked automatically.