← How-To Guides How-To How to use Counter Use collections.Counter(iterable) for frequency counts. most_common(n) returns top n. Counter Counter subclasses dict. from collections import Counter c = Counter('abracadabra') print(c.most_common(2))