Python tuple() built-in function
From the Python 3 documentation
Rather than being a function, tuple is actually an immutable sequence type, as documented in Tuples and Sequence Types — list, tuple, range.
Introduction
While tuple
is technically a type, it can be used like a function to create tuples. Tuples are immutable sequences, meaning they cannot be changed after they are created.
The tuple()
constructor can be used to create an empty tuple or to convert an iterable (like a list) into a tuple.
Examples
Create an empty tuple:
empty_tuple = tuple()
print(empty_tuple) # Output: ()
Create a tuple from a list:
my_list = [1, 2, 3]
my_tuple = tuple(my_list)
print(my_tuple) # Output: (1, 2, 3)