Skip to content

Instantly share code, notes, and snippets.

@tomwolber
Created September 30, 2011 15:47
Show Gist options
  • Save tomwolber/1254176 to your computer and use it in GitHub Desktop.
Save tomwolber/1254176 to your computer and use it in GitHub Desktop.
collections.Counter example
>>> 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