I am working on lists of list
input:
x = [['a','a','a'],['b','b','b'],['c','c','c'],['d','d','d']]
and am looking for an output:
s = ['a_b_c_d','a_b_c_d','a_b_c_d']
Kindly let me know how can I do this using list comprehension.
>>> x = [['a','a','a'],['b','b','b'],['c','c','c'],['d','d','d']]
>>> map('_'.join, zip(*x))
['a_b_c_d', 'a_b_c_d', 'a_b_c_d']
… although @aix's list comprehension is more list-comprehensible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With