Skip to content

Instantly share code, notes, and snippets.

@RenSys
Last active February 17, 2017 08:20
Show Gist options
  • Save RenSys/cfc83ef7669d6831ef425d9e848bcb4e to your computer and use it in GitHub Desktop.
Save RenSys/cfc83ef7669d6831ef425d9e848bcb4e to your computer and use it in GitHub Desktop.
Count the number of unique items in a list
from collections import Counter
word_count = Counter('my my name is is is Hal hal'.split())
for word, count in word_count.items():
print 'Word Count: {} -> {}'.format(count, word)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment