Created
January 18, 2013 22:10
-
-
Save ricardoanguiano/4569077 to your computer and use it in GitHub Desktop.
Generate a histogram from standard input.
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
#!/usr/bin/python | |
import sys | |
dict = {} | |
#f = open (sys.argv[1]) | |
for line in sys.stdin: | |
line = line.strip() | |
if line in dict: | |
dict[line] += 1 | |
else: | |
dict[line] = 1 | |
for (a,b) in dict.items(): | |
print "%i %s" % (b, a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment