title: how to compare one item in a list with all the other items in this list, python
body: <p>I have a list like this:</p>
  
  <pre><code> all = [[a,b,c,d],[r,d,g,s],[e,r,a,b],[p,o,i,u]....(more similar items)]
  </code></pre>
  
  <p>I want to get how many items are the same among them, so I need to compare <code>all[0]</code> with <code>all[1],all[2]...all[(len(all)-1)]</code>, and then use <code>all[1]</code> to compare with <code>all[2],all[3]...all[(len(all)-1)]</code>, then <code>all[2]</code> to compare with <code>all[3],all[4],...all[(len(all)-1)]</code></p>
  
  <p>I tried something like this:</p>
  
  <pre><code> for i in range(len(all)):
       print len(all[i] &amp; all[i+1]) ##how many identical items shared by all[0] and all[1]
       print len(all[i+1] &amp; all[i+2])
  </code></pre>
  
  <p>but don't know how to continue, The result I want to get is:</p>
  
  <pre><code>item1 has 3 same values with item2, 
        has 4 same values with item3,
        has 1 same values with item4....
  
  item2 has 3 same values with item1,
        has 2 same values with item3,
        etc
  </code></pre>