some_product += another_product
I have just started learning python so I am very new to the language, and I am struggling to understand what += means.
some_product += another_product
I have just started learning python so I am very new to the language, and I am struggling to understand what += means.
here is a very simple example of how to add to a variable a number:
a = 1
# we want to add to a 5
a = a + 5
print(a)
# output: 6
or:
a = 1
a += 5 # equivalent with a = a + 5
print(a)
# output: 6
similar:
some_product += another_product
is equivalent with: some_product = some_product + another_product
, assuming that your variables are integers or other numeric types