Don't like ads? PRO users don't see any ads ;-)
Guest

code counter

By: reidhoruff on Sep 10th, 2011  |  syntax: Python  |  size: 0.43 KB  |  hits: 72  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. valueCount = {}
  2.  
  3. def process( input ):
  4.    
  5.     for line in input:
  6.         for char in line.strip():
  7.             if valueCount.has_key(char.lower()):
  8.                 valueCount[char.lower()] += 1
  9.             else:
  10.                 valueCount[char.lower()] = 1
  11.                
  12.                
  13.                
  14. def printRes():
  15.    
  16.     for w in sorted(valueCount, key=valueCount.get, reverse=True):
  17.         print w, valueCount[w]