Reputation: 14037
How to convert
[('a',1),('b',3)]
to
[('a','1'),('b','3')]
My end goal is to get:
['a 1','b 3']
I tried:
[' '.join(col).strip() for col in [('a',1),('b',3)]]
and
[' '.join(str(col)).strip() for col in [('a',1),('b',3)]]
Upvotes: 1
Views: 209
Reputation: 7727
If you want to avoid the list comprehensions in jme's answer:
mylist = [('a',1),('b',3)]
map(lambda xs: ' '.join(map(str, xs)), mylist)
Upvotes: 2
Reputation: 20695
This ought to do it:
>>> x = [('a',1),('b',3)]
>>> [' '.join(str(y) for y in pair) for pair in x]
['a 1', 'b 3']
Upvotes: 4