Reputation: 79
I have the following sublist:
[['a', 'b'], ['c', 'd'], ['e', 'f'], ['g']]
But is it possible to join the list in the sublist?
[['ab'], ['cd'], ['ef'], ['g']]
Upvotes: 2
Views: 794
Reputation: 113
Also, you can use map for it
>>> L = [['a', 'b'], ['c', 'd'], ['e', 'f'], ['g']]
>>> map(lambda x: [''.join(x)], L)
[['ab'], ['cd'], ['ef'], ['g']]
Upvotes: -1
Reputation: 133514
>>> L = [['a', 'b'], ['c', 'd'], ['e', 'f'], ['g']]
>>> [[''.join(x)] for x in L]
[['ab'], ['cd'], ['ef'], ['g']]
Upvotes: 6