Ask coding questions

← Back to all posts
How would you multiply lists?
pandadrum (0)

How would you multiply lists? It is supposed to be an easy problem please help me!
L❤ve,
Anonymus

Comments
hotnewtop
RYANTADIPARTHI (6010)

Solution

if you want to multiple each element of the list into a new list, try this.

list1 = [1, 2, 3]
list2 = [4, 5, 6]

answer = [a * b for a, b in zip(list1, list2)]
print(answer)

like that.
That should work

SixBeeps (5067)

Are you looking to multiply all the numbers in a list together, or rather perform cross/dot products?