How to join tuple item from a list of tuples into a list with Python

2 Answers

0 votes
lst_tpl = [('a', 'b'), ('x', 'y', 'z', 'w'), ('c', 'o', 'p')] 

result = [' '.join(tpl) for tpl in lst_tpl] 
  
print (str(result)) 



'''
run:

['a b', 'x y z w', 'c o p']

'''

 



answered Dec 19, 2019 by avibootz
0 votes
lst_tpl = [('a', 'b'), ('x', 'y', 'z', 'w'), ('c', 'o', 'p')] 

result = list(map(" ".join, lst_tpl)) 
  
print (str(result)) 



'''
run:

['a b', 'x y z w', 'c o p']

'''

 



answered Dec 19, 2019 by avibootz

Related questions

1 answer 238 views
2 answers 159 views
1 answer 225 views
2 answers 228 views
2 answers 248 views
...