title: How to find elements existing in two lists but with different indexes
body: <p>I have two lists of the same length which contains a variety of different elements. I'm trying to compare them to find the number of elements which exist in both lists, but have different indexes.</p>
  
  <p>Here are some example inputs/outputs to demonstrate what I mean:</p>
  
  <pre><code>&gt;&gt;&gt; compare([1, 2, 3, 4], [4, 3, 2, 1])
  4
  &gt;&gt;&gt; compare([1, 2, 3], [1, 2, 3])
  0
  # Each item in the first list has the same index in the other
  &gt;&gt;&gt; compare([1, 2, 4, 4], [1, 4, 4, 2])
  2
  # The 3rd '4' in both lists don't count, since they have the same indexes
  &gt;&gt;&gt; compare([1, 2, 3, 3], [5, 3, 5, 5])
  1
  # Duplicates don't count
  </code></pre>
  
  <p>The lists are always the same size.</p>
  
  <p>This is the algorithm I have so far:</p>
  
  <pre><code>def compare(list1, list2):
      # Eliminate any direct matches
      list1 = [a for (a, b) in zip(list1, list2) if a != b]
      list2 = [b for (a, b) in zip(list1, list2) if a != b]
  
      out = 0
      for possible in list1:
          if possible in list2:
              index = list2.index(possible)
              del list2[index]
              out += 1
      return out
  </code></pre>
  
  <p>Is there a more concise and eloquent way to do the same thing?</p>