Python tuple()

In Python, a tuple is an immutable sequence type. One of the ways of creating tuple is by using the tuple() construct.


The syntax of tuple() is:

tuple(iterable)

tuple() Parameters

  • iterable​ (optional) - an iterable (list, range, etc.) or an iterator object

If the iterable is not passed to tuple(), the function returns an empty tuple.


Example: Create tuples using tuple()

Output

t1 = ()
t2 = (1, 4, 6)
t1 = ('P', 'y', 't', 'h', 'o', 'n')
t1 = (1, 2)

Recommended reading: Python Tuples