title: Sum of comparisons in a list Python
body: <p>First time on here but what is the easy way to find the sum of all duplicates in two lists? Additionally, it so happens that these lists are defined within object &quot;Person&quot;</p>
  <pre><code>p1=Person(&quot;Jack&quot;, [], [ 1 , 3 , 5 ])
  p2=Person(&quot;Dave&quot;, [], [ 1 , 2 , 5 ])
  </code></pre>
  <p>a = [ 1 , 3, 5]
  b = [ 1 , 2, 5]</p>
  <p>comparing the two lists, count = 2 index 0 and 2 are the same in both lists.</p>
  <p>I've got some java intuition that tells me to just use a for loop that counts up through each value make the comparison and then add one to count.</p>
  <p>sort of like what's going on here but it's not right</p>
  <pre><code>def compare(x1, x2):
  count=0
  for x in parray:
      if x1.qarray[x] == x2.qarray[x]:
          count+=1
  print(count)
  </code></pre>