I know that I should be using a for loop, but I can´t figure out how exactly.
def product_list(list):
for item in list:
I´ve search about this isse, but i´ve found replies that involves map() and lambda. How may I do it with a loop?
for-looploopspython
I know that I should be using a for loop, but I can´t figure out how exactly.
def product_list(list):
for item in list:
I´ve search about this isse, but i´ve found replies that involves map() and lambda. How may I do it with a loop?
Best Answer
Use a temporary variable, and multiply each item to it:
A better way would be to use
reduce()
withoperator.mul
: