title: Trying to find the average of multiple values in a dictionary
body: <p>New to python here. Trying to get find the average of totaled up keys in a dictionary.</p>
  
  <p>I've managed to grab the total of all values for each key, but I'm not certain how to find the average of these new values.</p>
  
  <pre><code>import os
  
  f = open("iris.data", "r")
  count = 0
  d = {}
  # You want the dictionary to have d = {Iris-setosa: list of values]
  # Populate dictionary
  # Code would work regardless of file
  # Reference movie names file
  
  for line in f:
      if line.isspace():
          continue #If a particular line is made of just spaces, ignore it
      strip = line.strip("\n") #Strips out that particular string
      data = strip.split(",")
      name = data[4]
  
      if name in d:
          for i in range(len(data)-1):
              d[name][i] += float(data[i])
          d[name][4] += 1 #increment count
          count += 1
      else:
          d[name] = [float(i) for i in data[0:4]]
          d[name].append(1) #keep count
          count = 1
  print(d)
  
  f.close
  </code></pre>