Tuple (Python)

A tuple is an ordered collection of items written in parentheses. It works like a list but is immutable, so its contents can't be changed after creation.

Python

Tuples are often used for fixed groups of values, such as coordinates, and can be used as dictionary keys because they are immutable. You can unpack a tuple into separate variables in one line.

Syntax

point = (x, y)

Examples

Python

point = (3, 4)
x, y = point
print(x, y)

Output:

3 4

Learn it in a lesson

See also

Back to the Dictionary