Word frequency count FIXED by zetamatta

import sys,re
C={}
for L in sys.stdin:
 for W in re.sub(r"[^ a-z]","",L.lower()).split():C[W]=C.get(W,0)+1
for W in sorted(C.keys()):print C[W],W

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page