How to convert a list of tuples to one string
6 answers
You can use a list comprehension, which will iterate over the tuples and then iterate over each tuple, returning the element to join.
my_list = [('a', 'b', 'c'), ('d', 'e')]
s = ' '.join([item for tup in my_list for item in tup])
Understanding a list is equivalent to:
a = []
for tup in my_list:
for item in tup:
a.append(item)
+1
source to share