Product


#1



I got the code to work, but I want to know if there is a better solution.

Is there a way to sum, multiply ect items in a list without using a for loop or importing a new module?


def product(x):
    total = 1
    for i in x:
        total *= i
    return total


#2

This solution is very good?

You can make it look like no loop is used by reduce lambda, but this still uses a loop under the hood.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.