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

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -