# What does *= do?

#1

I've googled it as well. I'm not sure what it's function is.

Thanks

#2

It is an multiply and assign operator.

``````+=
-=
*=
/=
%=``````

When we have a given value in a variable,

``my_var = 6``

we can multiply it by a number and assign the result back to the variable

``````my_var *= 6
print my_var   # 36``````

Now,

``````my_var += 6
print my_var   # 42``````

and,

``````my_var /= 7
print my_var   # 6``````

finally,

``````my_var -= 3
print my_var   # 3``````

and,

``````my_var %= 3
print my_var   # 0``````

#3

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``````