Skip to content

Instantly share code, notes, and snippets.

@daltonmatos
Created April 8, 2012 00:09
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 daltonmatos/2333049 to your computer and use it in GitHub Desktop.
Save daltonmatos/2333049 to your computer and use it in GitHub Desktop.
Count words
import sys
users = {}
for line in sys.stdin:
username = line.strip('\n')
if username not in users:
users[username] = 1
else:
users[username] += 1
for k, v in users.iteritems():
print "{0} {1}".format(k, v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment