Python Tuples & Immutable Data
A tuple is like GPS coordinates or your birth date: once created, nobody can alter it. Tuples are written with parentheses (). They are faster than lists and guarantee that your data stays uncorrupted.
"If a list is a pencil drawing you can erase and modify, a tuple is carved in stone. You can look at it and read it as much as you like, but you cannot change what is written."
Deep Dive: How It Works
Tuples are ordered, immutable sequences. You define them with parentheses: point = (10, 20).
Why use tuples over lists? Security (prevents accidental modification), performance (slightly faster and more memory-efficient), and dictionaries allow tuples as keys whereas lists are not allowed.
Tuple Unpacking: Python allows you to assign elements of a tuple to multiple variables in one line: lat, lon = (37.77, -122.41).
Single-item tuple quirk: To create a tuple with one item, you must include a trailing comma: single = (42,). Without the comma, Python treats (42) as a parenthesized integer.
Syntax Blueprint
coords = (10, 20) # Tuple with 2 items x, y = coords # Unpack into x and y first = coords[0] # 10
Use parentheses () for tuples. They support indexing and unpacking like lists, but cannot be modified.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Trying to modify a tuple: coords[0] = 99Why it happens: Tuples do not support item assignment.
How to fix: If you need to change values, use a list [] instead of a tuple ().
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Unpack a tuple
Given dimensions = (1920, 1080), unpack it into width and height.
Print width.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.