title: Python- How to find the average of multiple values/key in a dictionary
body: <p>I have a dictionary that looks like this. . . </p>
  
  <pre><code>CombinedDict = {'Abamectin': [63, 31, 53], 'Difenzoquat metilsulfate': [185, 49, 152], 'Chlorpyrifos': [14, 26, 56], 'Dibutyl phthalate': [25, -17, -18] 
  </code></pre>
  
  <p>and so forth. In total I have 48 different keys. </p>
  
  <p>What I am trying to get is the average of the three numbers. So I would get a dict that looks like this . . . </p>
  
  <pre><code>  AvgDictName = {'Abamectin': [49], 'Difenzoquat metilsulfate': [128], 'Chlorpyrifos': [32], 'Dibutyl phthalate': [-3] . . . 
  </code></pre>
  
  <p>I have tried using this line</p>
  
  <pre><code>    AvgDictName = dict([(key, float(sum([int(i) for i in values])) / len(values)) for key, values in CombinedDict])
  </code></pre>
  
  <p>But I am getting <em>too many values to unpack error</em>
  Any ideas? I think it could also be done by making the dict into a list and finding the average from a list using len and sum commands and then converting back to a dict but I do not really know how to go about that. Thank you, I have a feeling this should easy.</p>