Add a column to a list of lists

I have two lists of the same dimension, now I try to add to “a”, a fourth column at the end with the values of “b [2]”.

a = [['3', 'LP', 132.5], 
 ['9', 'AP', -153.7], 
 ['18', 'DN', 11.7]]


b = [['3', 'AP', -103.3],
 ['9', 'CL', 131.8], 
 ['18', 'DN', -55.0]]

The result should be something like this:

result = [['3', 'LP', 132.5, -103.3], 
 ['9', 'AP', -153.7, 131.8], 
 ['18', 'DN', 11.7, -55.0]]

I have tried with the “append” method, and I almost get it, some suggestions?

Answer

a = [['3', 'LP', 132.5],
     ['9', 'AP', -153.7],
     ['18', 'DN', 11.7]]

b = [['3', 'AP', -103.3],
     ['9', 'CL', 131.8],
     ['18', 'DN', -55.0]]

result = []
for i, v in enumerate(a):
    result.append(v.copy())
    result[-1].append(b[i][2])

print(result) # [['3', 'LP', 132.5, -103.3], ['9', 'AP', -153.7, 131.8], ['18', 'DN', 11.7, -55.0]]

or with list comprehension:

result = [v.copy() + b[i][2:3] for i, v in enumerate(a)]
print(result) # [['3', 'LP', 132.5, -103.3], ['9', 'AP', -153.7, 131.8], ['18', 'DN', 11.7, -55.0]]