+4 votes
in Programming Languages by (74.2k 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

+1 vote
by (350k points)
selected by
 
Best answer

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


...