What is the neatest way to multiply element-wise a list of lists of numbers?
E.g.
[[1,2,3],[2,3,4],[3,4,5]] -> [6,24,60]
Use a list comprehension and reduce:
reduce
>>> from operator import mul >>> lis = [[1,2,3],[2,3,4],[3,4,5]] >>> [reduce(mul, x) for x in lis] [6, 24, 60]