title: In python, how do I find the sum of values in a dictionary? Where each key has multiple values
body: <p>My data is tab delimited and looks like this:</p>
  
  <pre><code>Name   Count    Sample
  Dog    .0001    1
  Dog    .00003   1
  Dog    .0001    2
  Cat    .0004    1
  Cat    .0002    1
  Cat    .0003    2
  Cat    .0002    2
  </code></pre>
  
  <p>After i define my variables unid as the first column merged with the 3rd column (ex Dog_1) and num as the Count for that line, i append each num into a dictionary under the unid (using Python 2.7), like so:</p>
  
  <pre><code>for line in K:
          sp = line.split("\t")
          name = sp[0]
          unid = sp[3][:-2] +"_"+ sp[0]
          num = int(Decimal(sp[1]))
          if not dict1.has_key(unid):
              dict1[unid] = []
          dict1[unid].append(num)
  </code></pre>
  
  <p>I try to sum it with this:</p>
  
  <pre><code>dictTot = sum(dict1.values())
  </code></pre>
  
  <p>But i get this error message:</p>
  
  <pre><code>TypeError: unsupported operand type(s) for +: 'int' and 'list'
  </code></pre>
  
  <p>How can I sum these values such that I can retrieve <code>Cat_1: .0006, Cat_2: .0005</code>  etc?</p>
  
  <p>Sorry everyone, as I know my ? is not great. But as stated by Jacob below, 
  "dictTot = sum(sum(value) for value in dict1.values())" sums all of the sums, but what I am looking for is to sum each group of values under each key independently so I can find out how many Cats there are in sample 1 and so on.  Perhaps sum is not right for this?  Sorry, as evident I am not a Python extraordinaire.</p>