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

NameTypeDescription
targetsingle assignment targetRead and update this location once.
expressionexpressionRight-hand operand.

Working Example

Example Snippetpython
a = [1]b = aa += [2]print((a is b, b))
Python Reference