Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 10, 2020 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/a8cffec8a56ac066ac41e0c7c5eeda28 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/a8cffec8a56ac066ac41e0c7c5eeda28 to your computer and use it in GitHub Desktop.
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