title: Filtering a (Nx1) list in Python
body: <p>I have a list of the form</p>
  
  <pre><code>[(2,3),(4,3),(3,4),(1,4),(5,4),(6,5)]
  </code></pre>
  
  <p>I want to scan the list and return those elements whose <code>(i,1)</code> are repeated. (I apologize I couldn't frame this better)</p>
  
  <p>For example, in the given list the pairs are <code>(2,3),(4,3)</code> and I see that 3 is repeated so I wish to return 2 and 4. Similarly, from <code>(3,4),(1,4),(5,4)</code> I will return 3, 1, and 5 because 4 is repeated.</p>
  
  <p>I have implemented the bubble search but that is obviously very slow.</p>
  
  <pre><code>for i in range(0,p):
  
      for j in range(i+1,p):
          if (arr[i][1] == arr[j][1]):
              print(arr[i][0],arr[j][0])
  </code></pre>
  
  <p>How do I go about it?</p>