You were very close. The problem was understanding the list that you had in understanding the dictionary. mydict[k], mydictcorr[k] both returned floats, but you tried to [xy for x, y in mydict[k], mydictcorr[k]] over them [xy for x, y in mydict[k], mydictcorr[k]] .
This will work for you:
def sub(base, subtract): corrected = [] for base_dict, sub_dict in zip(base, subtract): corrected.append({k: v - sub_dict.get(k, 0) for k, v in base_dict.items()}) return corrected
Or as a much less readable single line (because I wanted to see if I could):
def sub(base, subtract): return [{k: v - sub_dict.get(k, 0) for k, v in base_dict.items()} for base_dict, sub_dict in zip(base, subtract)]
Having said that, you can still see some strange results when you subtract the floats. For example, {'Tom': 3.999999999999999} . You can wrap v - sub_dict.get(k, 0) when calling round.
source share