Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Counting With Python's Counter (Summary)

When you need to count several repeated objects in Python, you can use Counter from collections. This class provides an efficient and Pythonic way to count things without the need for using traditional techniques involving loops and nested data structures. This can make your code cleaner and faster.

In this video course, you learned how to:

  • Count several repeated objects using different Python tools
  • Create quick and efficient counters with Python’s Counter
  • Retrieve the most common objects in a particular counter
  • Update and manipulate object counts
  • Use Counter to facilitate further computations
  • Implement Counter instances as multisets

For more information on concepts covered in this course, you can check out:

Download

Sample Code (.zip)

5.5 KB

Download

Course Slides (.pdf)

1001.8 KB

James on March 10, 2022

Nicely done. Examples are good.

Become a Member to join the conversation.