Python tuple() Syntax

Syntax: tuple(iterable)

  • iterable (optional): It is an iterable(list, range etc..) or an iterator object
    •  If an iterable is passed, the corresponding tuple is created,
    • else, an empty tuple is created.

Return: Returns a Tuple

It raises a TypeError, if an iterable is not passed. Below programs illustrate tuple() function in Python.

tuple() Function in Python

The Python tuple() function is a built-in function in Python that can be used to create a tuple. A tuple is an ordered and immutable sequence type.

Example:

Python3




l = [1,2,3]
print(tuple(l))


Output:

(1, 2, 3)

Similar Reads

Python tuple() Syntax

...

tuple() in Python Function Examples

Syntax: tuple(iterable) iterable (optional): It is an iterable(list, range etc..) or an iterator object  If an iterable is passed, the corresponding tuple is created, else, an empty tuple is created. Return: Returns a Tuple...

Tuple() Built-In Functions

Create tuples using tuple()...