title: How to compute the "least occurring" elements in a Python list?
body: <p>Let's say I have a python list:</p>
  
  <pre><code>foo = ['A', 'A', 'A', 'B', 'C', 'C']
  </code></pre>
  
  <p>How would I be able to extract the "least occurring" elements in the list? </p>
  
  <p>Finding the majority elements is easier, doing the following:</p>
  
  <pre><code>print(max(foo, key=foo.count))
  'A'
  </code></pre>
  
  <p>However, how could I efficiently find the least occurring? In the above example, it's <code>'B'</code>.</p>
  
  <p>In terms of lists whereby all counts are the same, e.g. <code>['A', 'B', 'C', 'D']</code>, I think all items are "least occurring". </p>