How to multiply two lists in Python

3 Answers

0 votes
list1 = [1, 4, 6, 0, 9, 2]
list2 = [3, 7, 8, 5, 1, 4]

multiply = [x*y for x,y in zip(list1, list2)]

print(multiply)



'''
run:

[3, 28, 48, 0, 9, 8]

'''

 



answered Apr 18, 2021 by avibootz
0 votes
import numpy as np

list1 = [1, 4, 6, 0, 9, 2]
list2 = [3, 7, 8, 5, 1, 4]

multiply = np.multiply(list1, list2)

print(multiply)



'''
run:

[ 3 28 48  0  9  8]

'''

 



answered Apr 18, 2021 by avibootz
0 votes
list1 = [1, 4, 6, 0, 9, 2]
list2 = [3, 7, 8, 5, 1, 4]
 
multiply = list(map(lambda x,y: x*y ,list1, list2))
 
print(multiply)
 
 
 
'''
run:
 
[3, 28, 48, 0, 9, 8]
 
'''

 



answered Apr 18, 2021 by avibootz

Related questions

3 answers 229 views
229 views asked Apr 18, 2021 by avibootz
1 answer 240 views
1 answer 245 views
1 answer 173 views
173 views asked Feb 27, 2019 by avibootz
1 answer 93 views
1 answer 156 views
156 views asked Apr 11, 2019 by avibootz
...