-
-
Save IndhumathyChelliah/65184ccada9114159dfe043793c61a10 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
c=Counter({'a':1,'b':2,'c':-5}) | |
#list unique elements | |
print (list(c))#Output:['a', 'b', 'c'] | |
#converts to set containing elements | |
print (set(c))#Output:{'c', 'a', 'b'} | |
#converts to a regular dictionary | |
print (dict(c))#Output:{'a': 1, 'b': 2, 'c': -5} | |
#convert to list of tuple. | |
print (c.items())#Output:dict_items([('a', 1), ('b', 2), ('c', -5)]) | |
#Converting form list of tuples | |
c1=Counter([('a',1),('b',2)]) | |
print (c1)#Output:Counter({('a', 1): 1, ('b', 2): 1}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment