Language Syntax
Augmented assignment — Python syntax
Evaluate the target once, perform the in-place operation if supported, then assign the result. Mutable objects may change through aliases; immutable ones generally produce a replacement. Unlike plain assignment, target evaluation precedes the right operand. Unpacking targets are not supported.
Formal Syntax & Structure
python syntaxpython
target += expression # also -=, *=, etc.Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| target | single assignment target | Read and update this location once. |
| expression | expression | Right-hand operand. |
Working Example
Example Snippetpython
a = [1]b = aa += [2]print((a is b, b))