Skip to content

Instantly share code, notes, and snippets.

Created Jul 10, 2020
What would you like to do?
from collections import Counter
print (c)#Output:Counter({'c': 4, 'd': 3, 'a': 2, 'b': 1})
#n is not mentioned. It returns all elements in the counter from most common to least
print (most)#Output:[('c', 4), ('d', 3), ('a', 2), ('b', 1)]
#n is mentioned as 2. It returns only 2 elements having highest count
print (most1)#Output:[('c', 4), ('d', 3)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment