Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. old_dict = {"Pavel":1, "Iulian":2, "Timur":3}
  2.  
  3. new_dict = dict([(value, key) for key, value in old_dict.items()])
  4.    
  5. print ("Original dictionary is : ")
  6. print(old_dict)  
  7.  
  8. print()
  9.  
  10. print ("Dictionary after swapping is :  ")  
  11. print("keys: values")
  12. for i in new_dict:
  13.     print(i, " :  ", new_dict[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement