Python | Convert a list into tuple of lists

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

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

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

 
Method #2 : Using Map + Lambda

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

(['first'], ['second'], ['third'])

 
Method #3 : Using Map + zip

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

(['first'], ['second'], ['third'])


My Personal Notes arrow_drop_up