well you don't need lambda for this ...
sum(a*b for a, b in zip(list1, list2))
even zip() little less perfect ... to avoid creating a list, use python3 or itertools.izip :
sum(a*b for a, b in itertools.izip(list1, list2))
but if, for some craaaaazy reason, you really really wanted to use lambda, pass each list to the map separately:
sum(map(lambda a, b: a*b, list1, list2))
and even then you didnβt need lambda, the available product is available in the operator module:
sum(map(operator.mul, list1, list2))
but use the generator in the first or second example, it will usually be faster.
source share