list1 = [1, 2, 3] list2 = [4, 5, 6] # Product part product_for_sum = [] for i in range(0, len(list1)): product_for_sum.append(list1[i]*list2[i]) # Sum part sumproduct = sum(product_for_sum) print(sumproduct) # (1*4) + (2*5) + (3*6) # = 4 + 10 + 18 # = 32
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter