Product>>HELP


#1

def product(old_list):
    new_list = int[]
    for each in old_list:
        each *= old_list
        if each == old_list:
            new_list.append(each)
    return new_list

Please what is wrong with my code?


#2

this:

new_list = int[]

is invalid syntax, not sure what you are trying to achieve. here is what i would do:

inside the function declare a variable total and set it to 1
loop over the items in the list, multiply them with total:

total = total * each

after the loop return total


#3

Please can you explain it better?


#4

can you show an updated version of your code? You must have made some changes after my suggestion


#5

def product(old_list):
total = total * each
split = old_list.split()
for each in old_list:
if (each == split):
return split
return total

That is the updated version.


#6

def product(old_list):
   total = 1

def product(old_list):
   total = 1
   for each in old_list:
      total = total * each

are my instructions so confusing? This should calculate the total, now all you have to do, is return it


#7

Thank you, I got that.


#8

Your kind explanation helped me to understand the code. Thank you very much!


#9