from collections import Counter
alist=['a','b','a','c','c','a']
a_count=Counter(alist)
print(a_count)
print(a_count.most_common())
print(a_count.most_common(1))
Output :
Counter({
'a': 3, 'c': 2, 'b': 1})
[('a', 3), ('c', 2), ('b', 1)]
[('a', 3)]
Counter It will return the number of each value in the incoming list , Save... In a dictionary . Dictionary methods are supported , There are additional operations , for example most_common() Method , Returns all elements in descending order , If you pass in an integer n, It will return the largest number of the top n term .