Skip to content

Instantly share code, notes, and snippets.

@sspencer
Created March 21, 2011 18:28
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 sspencer/879929 to your computer and use it in GitHub Desktop.
Save sspencer/879929 to your computer and use it in GitHub Desktop.
Count items without conditional
t = ["one", "two", "one", "four", "one", "two", "three"]
hist = {}
for x in t:
hist[x] = hist.get(x, 0) + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment