Counting With Python's Counter

Christopher Trudeau

Counting several repeated objects at once is a common problem in programming. Python offers a bunch of tools and techniques you can use to approach this problem. However, Python’s Counter from collections provides a clean, efficient, and Pythonic solution.

This dictionary subclass provides efficient counting capabilities out of the box. Understanding Counter and how to use it efficiently is a convenient skill to have as a Python developer.

In this video course, you’ll learn how to:

  • Count several repeated objects at once
  • Create counters with Python’s Counter
  • Retrieve the most common objects in a counter
  • Update object counts
  • Use Counter to facilitate further computations
  • Implement Counter instances as multisets

What’s Included:

Downloadable Resources:

Related Learning Paths:

About Christopher Trudeau

Christopher has a passion for the Python language and writes for Real Python. He is a consultant who helps advise organizations on how to improve their technical teams.

» More about Christopher

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

← Browse All Courses