How about this :
l1 = [1, 2, 3]
l2 = [10, 100, 1000]
l3 = [ x*y for x in l1 for y in l2]
Question
I am trying to multiply all combinations of the numbers in 2 lists in python.
For Example
list(abc) and list(xyz) would return a*x a*y a*z b*x b*y b*z c*x c*y c*z
I am quite new to python and so I do not have much experience.
Solution
How about this :
l1 = [1, 2, 3]
l2 = [10, 100, 1000]
l3 = [ x*y for x in l1 for y in l2]
OTHER TIPS
Use the inbuilt zip function
l1 = [1, 2, 3]
l2 = [10, 100, 1000]
l3 = [i * j for i, j in zip(l1, l2)]