Full name
tuple
Library
Built-in
Syntax
class tuple([iterable])
Description
The tuple class returns an immutable iterable object of type tuple (a tuple).
Parameters
- iterable: Iterable object whose elements we want to include in the generated tuple.
Result
The returned result is a tuple.
Examples
If we start from an iterable such as, for example, a list:
a = [1, 3, "Python", True, 3 + 2j]
a
[1, 3, 'Python', True, (3 + 2j)]
...we can create a tuple with the following code:
tuple(a)
(1, 3, 'Python', True, (3 + 2j))