Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created Jul 10, 2020
Embed
What would you like to do?
from collections import Counter
c=Counter()
print (c)
c1=Counter([1,2,3,1,2,3,4,5,6])
#key are elements and corresponding values are their frequencies
print (c1)#Output:Counter({1: 2, 2: 2, 3: 2, 4: 1, 5: 1, 6: 1})
c2=Counter({'a':1,'b':3,'c':5,'d':5})
print (c2)#Output:Counter({'c': 5, 'd': 5, 'b': 3, 'a': 1})
c3=Counter(a=4,b=5)
print (c3)#Output:Counter({'b': 5, 'a': 4})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment