Merging two lists with python? -
i want merge 2 lists :
a=['a','b','c'] b=['1','2','3']
i want result :
c = ['a1','b2','c3']
any ideas in python 3. thanks!
you can use zip()
function within list comprehension :
>>> ['{}{}'.format(i,j) i,j in zip(a,b)] ['a1', 'b2', 'c3']
or str.join()
:
>>> [''.join(i) in zip(a,b)] ['a1', 'b2', 'c3']
Comments
Post a Comment