title: Totaling occurrences of an element in a dictionary of lists
body: <p>I have this dictionary of lists:</p>
  
  <pre><code>  d = {'Apple': [['Category1', 14], ['Category2', 12], ['Category2', 8]], 'Orange' : [['Category2', 12], ['Category2', 12], '[Category3', 2]]}
  </code></pre>
  
  <p>I would like the output to be like:</p>
  
  <pre><code>   d = {'Apple': [['Category1', 14], ['Category2', 20]],'Orange': [['Category2', 24], ['Category3', 2]]}
  </code></pre>
  
  <p>Category i.e <code>Category1, Category2</code> with the same name will be combined and totaled.</p>
  
  <p>I was thinking of a pseudocode of something like:</p>
  
  <pre><code>output = defaultdict(set)
  for key, value in d.items():
     for item in value:
        total += int(value[1])
        output[key].add(value[0],total)
     total = 0
  </code></pre>
  
  <p>Thanks</p>