Skip to content

Instantly share code, notes, and snippets.

@tomhartley
Created December 4, 2012 21:58
Show Gist options
  • Save tomhartley/4209227 to your computer and use it in GitHub Desktop.
Save tomhartley/4209227 to your computer and use it in GitHub Desktop.
Count word lengths
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