4 types of collections in python code example
Example 1: counter most_common
most_common([n])¶
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 arbitrarily:
>>> Counter('abracadabra').most_common(3)
[('a', 5), ('r', 2), ('b', 2)]
Example 2: python collections
list = [1,2,3,4,1,2,6,7,3,8,1]
Counter(list)