On this page
operator.countOf
Prev: operator.contains | Up: operator | Next: operator.delitem
Rel: operator.abs, operator.add, operator.and_, operator.attrgetter
Ref: docs.python.org — operator.countOf
Tags: #public #python3 #stdlib #operator
Import
import operator
from operator import countOf
Signature & Overview
operator.countOf(a, b, /)
Return the number of items in a which are, or which equal, b.
Usage
import operator
assert operator.countOf([1, 2, 1, 3, 1], 1) == 3
Gotchas
- Works on any iterable (even generators that don't have
.count()).
REPL Inspect
from operator import countOf
help(countOf)
Linked from
Related notes
- tuts/python3/stdlib_module/operator/contains Linked here; links to this page; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/delitem Linked here; links to this page; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/operator/abs Linked here; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/add Linked here; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/and_ Linked here; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/attrgetter Linked here; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/call shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/concat shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/eq shared tags: #operator, #stdlib