I have a Python dictionary, say dict1, with some key-value pairs. I'd like to create a new dictionary dict2, with the same keys, but different values, based on values in dict1. For example:
dict1 = {'A':4, 'B':7, 'C':5}
dict2 is somewhat like {'A':(4/t^2), 'B':7/(t^2), 'C':5/(t^2)}
, etc. based on some t
.
So the new dict2
values are created from dict1
values, for corresponding keys. I have tried looping using items, etc. but without much success.