Chaitanya Baweja
Oct 21, 2019 · 1 min read


Yes, Counts are always displayed in descending order of frequency. For example, you pass as argument ‘Hello World’ to a Counter() object. You would get the most frequent element, ‘l’ in this case first, then ‘o’, then everything else.

Here’s the code snippet to try this yourself:

from collections import Counter
my_count = Counter('Hello World')
# Output
# Counter({'l': 3, 'o': 2, 'H': 1, 'e': 1, ' ': 1, 'W': 1, 'r': 1, 'd': 1})

    Chaitanya Baweja

    Written by

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade