MemotivaStandard library essentials

What is collections.Counter?

Standard library essentials

Audio flashcard · 0:15

Nortren·

What is collections.Counter?

0:15

Counter is a dict subclass for counting hashable objects. It takes an iterable and produces a mapping from elements to their counts. It supports arithmetic operations between counters and methods like most_common to return the top elements. It is the idiomatic way to count occurrences.
docs.python.org