- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert list of tuples to list of strings in Python
During data processing using python, we may come across a list whose elements are tuples. And then we may further need to convert the tuples into a list of strings.
With join
The join() returns a string in which the elements of sequence have been joined by str separator. We will supply the list elements as parameter to this function and put the result into a list.
Example
listA = [('M','o','n'), ('d','a','y'), ('7', 'pm')] # Given list print("Given list : \n", listA) res = [''.join(i) for i in listA] # Result print("Final list: \n",res)
Output
Running the above code gives us the following result −
Given list : [('M', 'o', 'n'), ('d', 'a', 'y'), ('7', 'pm')] Final list: ['Mon', 'day', '7pm']
With map and join
We will take a similar approach as above but use the map function to apply the join method. Finally wrap the result inside a list using the list method.
Example
listA = [('M','o','n'), ('d','a','y'), ('7', 'pm')] # Given list print("Given list : \n", listA) res = list(map(''.join, listA)) # Result print("Final list: \n",res)
Output
Running the above code gives us the following result −
Given list : [('M', 'o', 'n'), ('d', 'a', 'y'), ('7', 'pm')] Final list: ['Mon', 'day', '7pm']
- Related Articles
- Convert list of strings to list of tuples in Python
- Convert list of tuples to list of list in Python
- Convert list of tuples into list in Python
- Convert dictionary to list of tuples in Python
- Convert list of tuples into digits in Python
- Convert list of strings and characters to list of characters in Python
- Python program to convert a list of tuples into Dictionary
- Python program to convert elements in a list of Tuples to Float
- Combining tuples in list of tuples in Python
- Python – To convert a list of strings with a delimiter to a list of tuple
- Python program to Convert a elements in a list of Tuples to Float
- Convert list of string to list of list in Python
- Count tuples occurrence in list of tuples in Python
- Python - Convert list of string to list of list
- Convert case of elements in a list of strings in Python

Advertisements