Operators

**= — Exponentiation assignment

Store a power of the existing value. A negative integer exponent can turn an integer into a float. Built-in zero raised to a negative exponent raises ZeroDivisionError. For x **= 3 ** 2, the exponent is evaluated as 3 ** 2 before the outer operation. The __ipow__() hook may modify its receiver or supply a replacement. If absent or declining with NotImplemented, normal binary dispatch applies. The result is stored back into the target; this is a statement, not an expression. A failed store does not guarantee rollback.

Formal Syntax & Structure

python syntaxpython
target **= expression

Parameters & Attributes

NameTypeDescription
targetobjectExisting assignable name, attribute, item or slice; its current value participates in the operation.
rightcompatible exponentValue used as the right operand of the operation.

Working Example

Example Snippetpython
factor = 2factor **= 3 ** 2reciprocal = 4reciprocal **= -1print(factor)print(reciprocal)
Python Reference