def normDictSumTo(d, sumTo=1):
  ''' Normalize the values of d to sumTo. The returned dict will
      have value sum = sumTo
  '''
  ks = d.keys()
  vs = d.values()  
  sum = reduce(lambda x,y:x+y, vs)
  vs= [ x/(sum*1.0)*sumTo for x in vs]
  return dict(zip(ks, vs))
 Normalize the values of d to sumTo. The returned dict will
      have value sum = sumTo
  
recipes/Python/278259_Dictionary_Tools/recipe-278259.py