13/15 product solution


#1

Im not sure where the usage of the "*=" operator was covered within codeacademy. I was stuck on this module, and found the solution below from the old forum here https://www.codecademy.com/forum_questions/52a9bf277c82ca5649001fbf.

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


#2

@anash28: the augmented assignment for addition was covered here but for the exercise you are reffering to, simply using total = total * i would also have been accepted.

As a reference for others who might stumble on your post in a far and distant future:

Here is what official Python Doc has to say on augmented assignment operators:

Augmented assignment is the combination, in a single statement, of a binary operation and an assignment statement
x += 1 can be rewritten as x = x + 1

Possible augmented assignment operations are:

+=     # addition
-=     # substraction
*=     # multiplication
/=     # divison
//=    # floor division
**=    # exponentiation
%=     # modulo
<<=    # left shift
>>=    # right shift
&=     # boolean AND
^=     # boolean XOR
|=     # boolean OR

What does *= do?
#3

Excellent! :grin: Thank you for the clarification