+2 votes
in Programming Languages by (75.1k points)
I have two lists and want to generate a new list that will have elements of two list concatenated.

E.g: Input lists:

aa = ['a','b','c']
bb = ['x','y','z']

Output list: ['ax', 'by', 'cz']

Any quick pythonic way?

1 Answer

+1 vote
by (353k points)
selected by
Best answer

Here are two simple approaches that you can try to get the desired result:

Approach 1:

aa = ['a','b','c']
bb = ['x','y','z']
def doConcatenate(i,j):
    return i+j
result = map(doConcatenate, aa, bb)
print (result)

Approach 2:

aa = ['a','b','c']
bb = ['x','y','z']
t = []
for i,j in zip(aa,bb):
print (t)