title: Counting occurrences in a Python list
body: <p>I have a list of integers; for example:</p>
  
  <pre><code>l = [1, 2, 3, 4, 4, 4, 1, 1, 1, 2]
  </code></pre>
  
  <p>I am trying to make a list of the three elements in <code>l</code> with the highest number of occurrences, in descending order of frequency. So in this case I want the list <code>[1, 4, 2]</code>, because <code>1</code> occurs the most in <code>l</code> (four times), <code>4</code> is next with three instances, and then <code>2</code> with two. I only want the top three results, so <code>3</code> (with only one instance) doesn't make the list.</p>
  
  <p>How can I generate that list?</p>