title: Count the number of elements of same value in Python
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2161752/how-to-count-the-frequency-of-the-elements-in-a-list">How to count the frequency of the elements in a list?</a>  </p>
  </blockquote>
  
  
  
  <p>I wish to count the number of elements of same value in a list and return a dict as such:</p>
  
  <pre><code>&gt; a = map(int,[x**0.5 for x in range(20)])
  &gt; a
  &gt; [0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4] 
  
  &gt; number_of_elements_by_value(a)
  &gt; {0:1, 1:3, 2:5, 3:7, 4:4}
  </code></pre>
  
  <p>I guess it is kind of a histogram?</p>