Python tuple() function

Published February 17, 2022

The tuple() method in Python is a built-in function that may be used to build a tuple.

The syntax of tuple() function
The tuple() method is written as follows

tuple(iterable)  


where an iterable can be a dictionary, a list, a range, etc.


Example

In the following example, we are going  to demonstrate the use of the tuple() function

my_list= [ 1, 2, 3, 4 ]
my_tuple = tuple(my_list)
print(my_tuple)

Output

(1, 2, 3, 4)

 

Read more about python Tuple with different examples

 

Download Source code

 

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

204 Views