Search code examples
pythonlistconcatenation

concatenate two element of different list as 1 variable in python


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

Solution

  • 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)]