13/15 Whats wrong with my code


def product(numbers): # mine, wrong
lst =
total = 1
for ele in numbers:
total *= ele
return total

print product([4,5,4])


First off, you could make the function a lot smaller if you just get rid of the lst list. Second, you are multiplying total by a string, not an integer. What you have to do is total *= int(ele).

The function I wrote for this was:

def product(numbers):
total = 1
for elein numbers:
return total

That is the function that I got, and I’m pretty sure it will work for codecademy.


Thank you, that looks like what I attempted. Im getting a bit confused when I need to add the blank list in my function.


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