Operator Functions

operator.setitem()

Assign value to a[b]. Mutates a supported target; does not return the assigned value.

Formal Syntax & Structure

python syntaxpython
operator.setitem(a, b, value, /)

Parameters & Attributes

NameTypeDescription
aobjectLeft operand or target object.
bobjectIndex, slice or mapping key.
valueobjectValue to assign.

Return Value

None

Returns None after performing the indicated mutation.

Working Example

Example Snippetpython
import operatordata=[1,2]print(operator.setitem(data,0,9))print(data)
Python Reference