Product


#1



Practice makes perfect: Product


This error message says that input 1,2 returned 1 instead of two.


I changed
total == 1 * numbers
I did this instead: total *= numbers 1
it works, but I don't understand why this works and my code didnt can someone explain?


def product(numbers):
    total = 1
    for i in numbers:
        total == i * total
    return total


#2

Bug in this line!

hint**
== is a comparison operator.

3 ==4 will return False
45 == 15 * 3will returnTrue

= is an assignment operator.

x = 5 # it means saving/putting value 5 in x


#3

What he means is that this:

total == i * total

should be this:

total = i * total


#4

I just tried the total = i * total and it worked


#5

def product(numbers):
total = 1
for i in numbers:
total = total * i
return total


#6

Why you're posting answers at each of the posts?
Read community Guidelines


#7

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