Assignment Operators
Assignment binds a name, while augmented assignment combines an operation with rebinding or mutation. Learn the difference when mutable objects are involved.
Understand the idea
For a number, += calculates a new numeric object and rebinds the name. A list's += commonly extends that existing list in place, which other aliases can observe. The spelling is compact, but it does not guarantee that no object identity changes or that the operation is atomic across threads.
Where to try it
Open this example with Try in playground. The code loads as editable text and does not run until you select Run. The first run downloads Python. Each run starts fresh; temporary files created by a script are not files on your PC.
A worked example
count = 2
count += 3
items = ["pen"]
alias = items
items += ["pad"]
print(count, alias)
Read the result
The output shows 5 and ['pen', 'pad']. alias sees the extended list because it refers to the same list object.
Try one change
Replace the list's += with items = items + ['pad'] and compare what alias contains.