Home / Python / Reference / Built-in functions

Python tuple() function

Make a new tuple (an unchangeable sequence).

Syntax

tuple(iterable=())

Tuples are like lists that cannot be changed after creation. Usually written directly with brackets and commas.

Parameters

iterableanything you can loop over

Return value

tuple

Example

Code

print(tuple([1, 2, 3]))
print(tuple("hi"))
point = (3, 4)
x, y = point
print(x, y, len(point))

Output

(1, 2, 3)
('h', 'i')
3 4 2
Good to know. A one-item tuple needs a comma: (5,). (5) is just the number 5.

Related

Learn it step by step in the free lesson Lists & Tuples, with exercises that check your answers.