ID EN
Collections

most_common

Python 3.11

Return a list of the n most common elements and their counts from the most common to the least. If n is omitted or None, most_common() returns all elements in the counter. Elements with equal counts are ordered in the order first encountered:

Syntax

PYTHON
most_common([n])

Examples

Example 1
PYTHON
>>> Counter('abracadabra').most_common(3)
[('a', 5), ('b', 2), ('r', 2)]

See Also

most_common()