title: finding duplicates in a list of lists
body: <p>I am using Python 2.7 and am trying to de-duplicate a list of lists and merge the values of the duplicates.</p>
  
  <p>Right now I have:</p>
  
  <pre><code>original_list = [['a', 1], ['b', 1], ['a', 1], ['b', 1], ['b', 2], ['c', 2], ['b', 3]]
  </code></pre>
  
  <p>I want to match on the first element of each nested list and then add the values of the second element. I want to end up with this (the order of the final list does not matter):</p>
  
  <pre><code>ideal_output = [['a', 2], ['b', 7], ['c', 2]]
  </code></pre>
  
  <p>So far I have some code that will find me the duplicate values based on the first element of each nested list:</p>
  
  <pre><code>for item in original_list:
      matches = -1
      for x in original_list:
          if (item[0] == x[0]):
              matches += 1
      if matches &gt;= 1: 
          if item[0] not in duplicates_list:
              duplicates_list.append(item[0])
  </code></pre>
  
  <p>From here I need to search for all duplicates_list items that are in original_list and add up the values, but I am not sure what the best way to do that is.</p>