Created
December 4, 2012 21:58
-
-
Save tomhartley/4209227 to your computer and use it in GitHub Desktop.
Count word lengths
This file contains hidden or 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 * | |
def countWordLength(txt): | |
count = collections.Counter() | |
words = txt.split() | |
for word in words: | |
count[len(word)]+=1 | |
return count | |
text = raw_input("Enter your text here yo: ") | |
print(countWordLength(text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment