Skip to content

Glossary: Python Beyond the Basics

Counter

Also written: collections.Counter, most_common

A tool from `collections` that counts how often each item appears. A missing item counts as 0 instead of raising KeyError, and `most_common(n)` returns the top n.

Where the book teaches it

Related terms

defaultdict