Python Tuples

Ordered collections that cannot change.

✍️ 3 exercises + code challenge in this lesson

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.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services