Back
+10 XP
Concept

Tuples: Immutable Sequences

Tuples are immutable lists defined with parentheses `()`. Once created, you cannot add, remove, or modify items.

python
point = (10, 20)
print(point[0])  # 10
# point[0] = 99  # TypeError! Tuples are frozen!

# 74. Tuples: Immutable Sequences Tuples are immutable lists defined with parentheses `()`: ```python point = (10, 20) print(point[0]) # 10 # point[0] = 99 # TypeError! Tuples are frozen! ``` Why use tuples over lists? They consume less RAM, execute slightly faster, and guarantee that nobody's sloppy code can accidentally mutate your configuration constants.

Checkpoint

What happens if you try to modify an item inside a tuple like `point[0] = 99`?

Practice

Create a tuple named `coords` with values `40.7` and `-74.0`. Print the tuple.

Terminal
01
Tap code blocks below to assemble
Available Blocks