title: Compare two lists of tuples
body: <pre><code>old = [('ver','1121'),('sign','89'),('address','A45'),('type','00')]
  new = [('ver','1121'),('sign','89'),('type','01')]
  </code></pre>
  
  <p>I need to compare the <code>new</code> list against <code>old</code> one based on first element of the tuples, and show the difference between whatever elements <code>new</code> list has, so that the output should look like:</p>
  
  <pre><code>Match     : ver   =   1121
  Match     : sign  =   89
  Mismatch  : type  =   01 (old : 00)
  </code></pre>
  
  <p>I could get all the matching tuples with below list comprehension but could not think beyond it.</p>
  
  <pre><code>my_list = [(a,b) for (a,b) in new for (c,d) in old  if ((a==c) and (b==d))]
  print( my_list)
  </code></pre>
  
  <p>Please suggest me a way to do it.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am sorry for not being clear on my question , I did not mention one more thing, the keys in the list can be repetitive, meaning the list can be like:</p>
  
  <pre><code>old = [('ver','1121'),('sign','89'),('address','A45'),('type','00'),('ver','sorry')]
  
  new = [('ver','1121'),('sign','89'),('type','01'),('ver','sorry)]
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Thanks to @holdenweb, I've made some changes to his code and this seems to be providing the expected output, please suggest if there are any flaws.</p>
  
  <pre><code>old = [('ver','1121'),('sign','89'),('address','A45'),('type','00'),('ver','works?')]
  new = [('ver','1121'),('sign','89'),('type','01'),('ver','This')]
  
  formatter = "{:12}: {:8} = {}".format
  newfmter = "{} (old : {})".format
  
  kv_old = []
  for i,(kn, vn) in enumerate(new):
      vo = [(j,(ko,vo)) for j,(ko, vo) in enumerate(old) if (ko==kn) ]
      for idx,(key,val) in vo:
          if idx &gt;=i:
              kv_old = [key,val]
              break;
  
      if kv_old[1]==vn:
          print(formatter("Match", kv_old[0], kv_old[1]))
      else:
          print(formatter("Mismatch", kn, newfmter(vn, kv_old[1])))
  </code></pre>