Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Python | Convert a list into tuple of lists

  • Last Updated : 13 Feb, 2019

We are given a list, the task is to convert the list into tuple of lists.

Input: ['Geeks', 'For', 'geeks']
Output: (['Geeks'], ['For'], ['geeks'])

Input: ['first', 'second', 'third']
Output: (['first'], ['second'], ['third'])

 
Method #1 : Using Comprehension

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course




# Python code to convert a list into tuple of lists
  
# Initialisation of list
Input = ['Geeks', 'for', 'geeks']
  
# Using list Comprehension
Output = tuple([name] for name in Input)
  
# printing output
print(Output)
Output:



(['Geeks'], ['for'], ['geeks'])

 
Method #2 : Using Map + Lambda




# Python code to convert a list into tuple of lists
  
# Initialisation of list
Input = ['first', 'second', 'third']
  
# Using map + lambda
Output = tuple(map(lambda x: [x], Input))
  
# printing output
print(Output)
Output:
(['first'], ['second'], ['third'])

 
Method #3 : Using Map + zip




# Python code to convert a list into tuple of lists
  
# Initialisation of list
Input = ['first', 'second', 'third']
  
# Using Map + zip
Output = tuple(map(list, zip(Input)))
  
# printing output
print(Output)
Output:
(['first'], ['second'], ['third'])



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!