Takes a list of integers as input and returns the product of all of the elements in the list

1
2
def product(listIntegers):
totalProduct = 1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This function takes a list of integers as input and returns the product of all of the elements in the list.

2 Responses

Try to call reduce(lambda x, y: x*y, [1, 2, 3]). Using built-in functions is more pythonic way.
@Sergey Olerinskiy Thanks for the hint Sergey!

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.