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 / weights_dict[key]
Everytime i get the error: unsupported operand type(s) for /: 'int' and 'function'
1st: How to make tke reciprocal for the dict values?
2nd: what is the cause for this error in my code?
Thanks!