0
Python +=
What does += mean in Python? https://code.sololearn.com/cEicz1yWXkCi/?ref=app
2 Answers
+ 4
+= is known as assignment operator in python.
i += 1
is treated as
i = i +1
+ 1
For immutable types like the int in your code,
i = 0
i += 1
would be the same as
i = i + 1
For a mutable type like a list, it would work similarly to the lists append() method.
a = [1,2,3]
b = [4,5,6]
a += b
a is now [1,2,3,4,5,6]
+= adds/appends/concatenates the R-value to the L-value and then assigns the result back to the L-value.