Explain the meaning of +=


#1



https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/1/4?curriculum_id=4f89dab3d788890003000096#


I was stuck in the beginning but I took a look at the solution here, I got my code working. I just need help about += symbole, what does it mean exactly ?


total = 0
for key in prices :
    total += prices[key]*stock[key]
print total


#2

The symbol is called a compound operator. It is compound because it consists of two operators, addition (+) and assignment (=). The addition operation takes place first,

x += 5

In the above 5 is added to the present value of x. The assignment operation replaces the current value with the new value, Consider the statement that this supplants..

x = x + 5

https://www.programiz.com/python-programming/operators


#3

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