1my_dict = {2:3, 5:6, 8:9}
2
3new_dict = {}
4for k, v in my_dict.items():
5 new_dict[v] = k
1my_dict = {'x':1, 'y':2, 'z':3}
2my_swapped_dict = {v: k for k, v in my_dict.items()}
3#{1: 'x', 2: 'y', 3: 'z'}
1old_dict = {'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69, 'G': 67, 'H': 23}
2
3new_dict = dict([(value, key) for key, value in old_dict.items()])
4print(new_dict)
5for i in new_dict:
6 print(i, " : ", new_dict[i])