def product(intlist):
for int in intlist:
total = total * int
return total

Am I on the right track here?


yes you are on the right there is only one pitfall.
in the first line of your code you are changing the input list to an empty one.
Therefore no matter what list you add to the method you will get nothing.
try to remove that line
Also int is a reserved keyword in python so i suggest you call your iterator
something else.
Remember you cannot use reserved keywords when naming variable, methods,classes etc


def product(cool):
total= 1
for int in cool:
total *= int
return total

Thank you @rydan ! I don't have any errors, but it is now saying

Your function fails on product([1, 2]). It returns 1 when it should return 2.

I'm not sure why this is the case. If you have time to explain, that would be great. In the meantime, I'll keep trying! Thanks :smile:


oh shoot never mind I just had to move the return back a tab. thanks!!


Hi @caldwell_646,

As you have just experienced with your return problem, indentation is important in the Python language and I wish to share with you a little trick that you can use whenever you need help in the forum. It will make it much easier for us to help you spot the problems in your code :smile:

Whenever you would like to paste code, since this forum supports Markdown Syntax you can use three backticks before and after your code block like so:

def my_func(x):
my_var = 0
if x > my_var:
sum = my_var + x
print "Odelay!"
return sum

and it will retain proper indentation and even have nifty syntax highlighting:

def my_func(x):
    my_var = 0
    if x > my_var:
      sum = my_var + x
      print "Odelay!"
    return sum


@denisaltroy oh thank you! This is my first time learning any sort of coding so any tips are helpful!


@caldwell_646: Welcome and have fun with the lessons :smile:


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

print product([4,5,5,10])