Created
September 30, 2011 15:47
-
-
Save tomwolber/1254176 to your computer and use it in GitHub Desktop.
collections.Counter example
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() | |
>>> c['t'] = 3 | |
>>> c | |
Counter({'t': 3}) | |
>>> c['r'] = 2 | |
>>> c | |
Counter({'t': 3, 'r': 2}) | |
>>> c['r'] += 1 | |
>>> c | |
Counter({'r': 3, 't': 3}) | |
>>> c['r'] -= 1 | |
>>> c | |
Counter({'t': 3, 'r': 2}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment