• Skip to primary navigation
  • Skip to content
  • Skip to footer
Looking for data in all the right places...
  • Portfolio
  • Posts
  • Categories
  • Tags
  • About
    Francis T. O'Donovan

    Francis T. O'Donovan

    Data Scientist – Planet discoverer, researcher, developer, geek.

    • Boston, MA
    • Website
    • Email
    • Bitbucket
    • GitHub
    • Google Scholar
    • KeyBase
    • LinkedIn
    • Medium
    • ORCiD
    • ResearchGate
    • StackOverflow
    • Mastodon
    • Keyoxide

    Python: Find the most common elements in an iterable

    April 5, 2017 less than 1 minute read

    >>> import collections
    >>> c = collections.Counter('helloworld')
    
    >>> c
    Counter({'l': 3, 'o': 2, 'e': 1, 'd': 1, 'h': 1, 'r': 1, 'w': 1})
    
    >>> c.most_common(3)
    [('l', 3), ('o', 2), ('e', 1)]
    

    Via Python Tricks.

    Tags: python, til

    Categories: til

    Updated: May 13, 2025

    Share on

    Twitter Facebook LinkedIn
    Previous Next

    Leave a comment

    You may also enjoy

    Culture turns strategy into action

    January 22, 2026 2 minute read

    Like many people, I enjoy working at startups with a mission I believe in. These companies match talented individuals with the latest technologies to solve i...

    Python: How uv got so fast

    January 9, 2026 less than 1 minute read

    I love uv, the latest python dependencies manager, and use it whenever I can.

    Stoicism and the pursuit of a good life

    December 17, 2025 2 minute read

    Given my first name, it’s probably not surprising that I am familiar with the Serenity Prayer:

    30 learnings from 30 years as a Python freelancer

    December 17, 2025 less than 1 minute read

    I found some tips and general thoughts on what it takes to be a successful freelancer, and why that career can be so fulfilling. Some highlights:

    • Follow:
    • Feed
    © 2026 Francis T. O'Donovan. Powered by Jekyll & Minimal Mistakes.