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

9.2

By: dvdjaco on Feb 18th, 2012  |  syntax: Python  |  size: 0.17 KB  |  hits: 20  |  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. # #!/usr/bin/python
  2. #
  3. # By dvdjaco
  4. # Exercise 9.1
  5. #
  6.  
  7. def histogram(s):
  8.         d = dict()
  9.         for c in s: d[c] = d.get(c,0) + 1              
  10.         return d
  11.  
  12. h = histogram('abcxxabcaba')
  13. print h