Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Python | Merge list of tuple into list by joining the strings

  • Last Updated : 02 Aug, 2019

Sometimes, we are required to convert list of tuples into a list by joining two element of tuple by a special character. This is usually with the cases with character to string conversion. This type of task is usually required in the development domain to merge the names into one element. Let’s discuss certain ways in which this can be performed.

Let’s try to understand it better with code examples.

 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

Method 1: Using list comprehension and join()






# Python code to convert list of tuple into list
# by joining elements of tuple
  
# Input list initialisation
Input = [('Hello', 'There'), ('Namastey', 'India'), ('Incredible', 'India')]
  
# using join and list comprehension
Output = ['_'.join(temp) for temp in Input]
  
# printing output
print(Output)
Output:
['Hello_There', 'Namastey_India', 'Incredible_India']

 
Method 2: Using map and join()




# Python code to convert list of tuple into list
# by joining elements of tuple
  
# Input list initialisation
Input = [('Hello', 'There'), ('Namastey', 'India'), ('Incredible', 'India')]
  
# using map and join
Output = list(map('_'.join, Input))
  
# printing output
print(Output)
Output:
['Hello_There', 'Namastey_India', 'Incredible_India']



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!