Skip to content
UPEEC

Tuples

Immutable ordered sequences — great for fixed records and returning several values.

Beginner
Comments 0
point = (10, 20)
x, y = point             # unpacking

def min_max(values):
    return min(values), max(values)   # returns a tuple

low, high = min_max([3, 9, 1])

Because tuples can't change, they can be used as dictionary keys and signal "this data is fixed".

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.