how to swap a key and value in a dict python code example
Example 1: switching keys and values in a dictionary in python [duplicate]
my_dict = {2:3, 5:6, 8:9}
new_dict = {}
for k, v in my_dict.items():
new_dict[v] = k
Example 2: how to change key to value and versa in python dictionary
dict = {value:key for key, value in dict.items()}