title: Deleting elements of a list based on a condition
body: <p>I have a list of elements from which I want to remove those elements whose count is less than or equal to 2 in all the list.</p>
  
  <p>For example:</p>
  
  <pre><code>A = [['a','b','c'],['b','d'],['c','d','e'],['c','e','f'],['b','c','e','g']]
  </code></pre>
  
  <p>I want to remove <code>'a'</code>, <code>'d'</code>, <code>'f'</code>, <code>'g'</code> from <code>A</code> and store the rest in <code>B</code> so that the list becomes:</p>
  
  <pre><code>B = [['b','c'],['b'],['c','e'],['c','e'],['b','c','e']]
  </code></pre>
  
  <p>I created a dictionary which will store all the count of elements and based on that I want to remove the elements with count less than or equal to 2.</p>
  
  <p>Below is the code which I have written so far.</p>
  
  <pre><code>for i in range(len(A)):
      for words in A[i]:
          word_count[words] +=1
      B = [A[i] for i in range(len(A)) if word_count[words]&lt;2]
  </code></pre>