How to convert a list into a tuple in Python?

PythonServer Side ProgrammingProgramming

You can convert a list into a tuple simply by passing to the tuple function. 

Example

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

Output

This will give the output −

(1, 2, 3)
raja
Published on 05-Jan-2018 17:32:29
Advertisements