+4 votes
in Programming Languages by (77.8k 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 (355k 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])
>>>


...