+4 votes
in Programming Languages by (14.3k points)
How can I multiply two python lists element-wise?

E.g.

x =[1, 2, 3]

y = [4, 5, 6]

result = [ 4, 10, 18]

1 Answer

0 votes
by (25.1k points)

You can use multiply() function of Numpy to compute the product of two lists element-wise.

E.g.

>>> x
array([1, 2, 3])
>>> y
array([4, 5, 6])
>>> np.multiply(x,y)
array([ 4, 10, 18])
>>>

...