def add_dicts_by_key(in_dict1, in_dict2):
 both = {}
 for key1 in in_dict1:
  for key2 in in_dict2:
   if (key1 == key2):
    both[key1] = (in_dict1[key1] + in_dict2[key2])
 return both

def add_dicts_by_key ( in_dict1 , in_dict2 ) : both = { } for key1 in in_dict1 : for key2 in in_dict2 : if ( key1 == key2 ) : both [ key1 ] = ( in_dict1 [ key1 ] + in_dict2 [ key2 ] ) return both
combines two dictionaries and adds the values for those keys that are shared .