Python | Merge list of tuple into list by joining the strings
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.
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) |
['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) |
['Hello_There', 'Namastey_India', 'Incredible_India']
Recommended Posts:
- Python | Ways to merge strings into list
- Python | Merge Tuple String List values to String
- Python program to create a list of tuples from given list having number and its cube in each tuple
- Python | Pair and combine nested list to tuple list
- Python | Convert Integral list to tuple list
- Python | Convert list to indexed tuple list
- Python | Merge List with common elements in a List of Lists
- Python | Sort tuple list by Nth element of tuple
- Python | Joining only adjacent words in list
- Python | Joining unicode list elements
- Python | Filter list of strings based on the substring list
- Python | Filter a list based on the given list of strings
- Python | Convert list of tuples to list of strings
- Python | Convert list of strings to list of tuples
- Python | Mean of tuple list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



