#!/usr/bin/python # prints frequency of words found in standard input import sys freq = {} # frequency of words in text for line in sys.stdin: for word in line.split(): # get method returns 2nd arg if the key isn't in dictionary freq[word] = freq.get(word,0) + 1 print freq