• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
August 04, 2022 |39.2K Views

Python Program to Convert a List into a Tuple

Description
Discussion

In this video, we will write a program to convert a list into a tuple in Python

We have used 3 approaches/methods to convert list into a tuple:
 
1. Convert a list into a tuple using typecasting 
2. Convert a list into a tuple using loop inside tuple method 
3. Convert a list into a tuple using dereferencing method 

The most simplest method is to use the typecasting method it convert any object to tuple object. 

The another method is to pick each element in the list using a loop and then convert it into tuple, it is almost similar to the last approach we discussed. 

The last method is to use the dereferencing method. This essentially unpacks the list inside a tuple literal which is created due to the presence of the single comma (, ). This approach suffers from readability but it is a bit faster approach

Convert list into a tuple:
https://www.geeksforgeeks.org/python-convert-a-list-into-a-tuple/