fork(1) download
  1. import sys
  2. import re
  3. from collections import Counter
  4.  
  5. c = Counter(re.split(r'[\-.,\s;:?!]+', sys.stdin.read().strip()))
  6.  
  7. for w, i in sorted(c.items()):
  8. if w:
  9. print "{0}:{1}".format(w, i)
  10. print "_________________________________\n"
  11. for w, i in c.most_common():
  12. if w:
  13. print "{0}:{1}".format(w, i)
  14.  
Success #stdin #stdout 0.01s 7868KB
stdin
yo - what, you;;
do you say	 what!

stdout
do:1
say:1
what:2
yo:1
you:2
_________________________________

what:2
you:2
do:1
yo:1
say:1