Home > Back-end >  concatenate two element of different list as 1 variable in python
concatenate two element of different list as 1 variable in python

Time:04-15

concatenate two elements as 1 element for example we are given two arrays a and b:

a=[1,2,3]
b=[4,5,6]

so what I want is an output as

14, 25, 36

CodePudding user response:

If a and b are lists of integers, you could do the following:

c = [i * 10   j for i, j in zip(a, b)]

If they are lists of strings, you could do the following:

c = [i   j for i, j in zip(a, b)]

CodePudding user response:

result = [int(str(x)   str(y)) for x, y in zip(a, b)]
  • Related