I have two lists, one is named as A, another is named as B. Each element in A is a triple, and each element in B is just an number. I would like to calculate the result defi
All above answers are correct, but in my opinion the most pythonic way to calculate dot product is:
>>> a=[1,2,3] >>> b=[4,5,6] >>> sum(map(lambda pair:pair[0]*pair[1],zip(a,b))) 32