Possible Duplicate:
How to count the frequency of the elements in a list?
I wish to count the number of elements of same value in a list and return a dict as such:
> a = map(int,[x**0.5 for x in range(20)])
> a
> [0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4]
> number_of_elements_by_value(a)
> {0:1, 1:3, 2:5, 3:7, 4:4}
I guess it is kind of a histogram?