There are many ways to write a Python program that computes a histogram.
By histogram, I mean a function that counts the occurrence of objects in an iterable>
iterable>
One that works back to 2.3 (slightly shorter than Timmerman's, I think more readable) :
L = 'abracadabra' hist = {} for x in L: hist[x] = hist.pop(x,0) + 1 print hist {'a': 5, 'r': 2, 'b': 2, 'c': 1, 'd': 1}