-
-
Save IndhumathyChelliah/a8cffec8a56ac066ac41e0c7c5eeda28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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