How can I multiply two python lists element-wise?

E.g.

x =[1, 2, 3]

y = [4, 5, 6]

result = [ 4, 10, 18]

E.g.

x =[1, 2, 3]

y = [4, 5, 6]

result = [ 4, 10, 18]

0 votes

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

>>>