I am trying to calculate the product of every element from one list multiplied by every element from another list. from each list multiplied by each other.
For example, in list1 I have 4, which needs to be multiplied by 3 in list2. Next, the 4 in list1 needs to be multiplied by 1 in list2. The pattern continues until I receive the output: [12,4,36,8,6,2,18,4,21,7,63,14]. I haven't been able to achieve this -- here is the code I have so far:
def multiply_lists(list1,list2):
for i in range(0,len(list1)):
products.append(list1[i]*list2[i])
return products
list1 = [4,2,7]
list2 = [3,1,9,2]
products = []
print ('list1 = ',list1,';','list2 = ', list2)
prod_list = multiply_lists(list1,list2)
print ('prod_list = ',prod_list)