def product(values): """Return the product of multiplying all the values. >>> product([3, 4, 5, 10]) 600 >>> product([]) 1 """ return reduce(operator.mul, values, 1)
def test_reduce(self): values = [1, 2, 3, 3, 6, 8, 9, 9, 12, 15, 0, 2, 7] self.assertEqual(reduce(operator.add, values), sum(values))