Last active
February 17, 2017 08:20
-
-
Save RenSys/cfc83ef7669d6831ef425d9e848bcb4e to your computer and use it in GitHub Desktop.
Count the number of unique items in a list
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 | |
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