resolve matrix lists with lambda and map

we have 3 lists in below


    [2,3,4]
    [5,6,7]
    [8,9,10]

so , how we can sum all of similar index in lists together? i mean is 2 and 5 and 8 be sum together & 3 and 6 and 9 also be sum together & 4 and 7 and 10 as well ? but just use lambda and map...

actually i have no idea for that and this code is just for sending this question


    x=[
    [5,8,1],
    [9,4,7],
    [2,6,3],
    ]
    
    
    print(list(map(lambda x : x[1], x)))


Solution 1:

You can zip your input data:

matrix = [[2,3,4],
          [5,6,7],
          [8,9,10]]

out = list(map(sum, zip(*matrix)))

Or using a list comprehension:

out = [sum(x) for x in zip(*matrix)]

Output: [15, 18, 21]