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
| Name | Type | Description |
|---|---|---|
| a | object | Left operand or target object. |
| b | object | Right operand. |
Return Value
int
The int result described above.
Working Example
Example Snippetpython
import operatorprint(operator.countOf([1,2,1],1))