Operator Functions

operator.countOf()

Count equal occurrences of b while traversing iterable a. Can consume an iterator; requires finite traversal to finish.

Formal Syntax & Structure

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

Parameters & Attributes

NameTypeDescription
aobjectLeft operand or target object.
bobjectRight operand.

Return Value

int

The int result described above.

Working Example

Example Snippetpython
import operatorprint(operator.countOf([1,2,1],1))
Python Reference