Problems with reciprocal of an dictionary
Problems with reciprocal of an dictionary Question: given dict: weights = {"A":16, "B": 3, "C": 5) I want to have the reciprocal of the values. Output: weights_dict_reci = {"A":0,0625, "B": 0,3333333, "C": 0,2) So far I tried: weights_dict_reci = {value: 1 / weights_dict[value] for value in weights_dict} and for key in weights_dict: weights_dict[key] = 1 …