Operator Functions

operator.contains()

Test whether b is contained in a. The container is the first argument, opposite the written order of b in a.

Formal Syntax & Structure

python syntaxpython
operator.contains(a, b, /)

Parameters & Attributes

NameTypeDescription
aobjectContainer to search.
bobjectValue whose membership is tested.

Return Value

bool

The bool result described above.

Working Example

Example Snippetpython
import operatorprint(operator.contains({"id": 7}, "id"))
Python Reference