Theory

Tuples are like lists, but they cannot be changed (immutable).

Create a tuple:

colors = ("red", "green", "blue")
point = (10, 20)

Access items like lists:

print(colors[0]) # red
print(colors[1]) # green

Tuples are useful for:
- Storing fixed data (coordinates, RGB colors)
- Returning multiple values from functions
- Using as dictionary keys

Unpack tuple values:

x, y = (10, 20)
print(x) # 10
print(y) # 20

Exercises in this lesson

2

Access Tuple Items

Given: rgb = (255, 128, 0) Print each color component on a separate line: - First (red): 255 - Second (green): 128 - Third (blue): 0

Easy Points: 15
Solve in the playground
Next lesson: Sets →