Guest User

Untitled

a guest
Dec 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. # key should be unique but value can be 'same' or any python object
  2. # unordered (doesnot support indexing or slicing)
  3. # mutable object
  4.  
  5. a = {}
  6. type(a)
  7. countries = {'np':'Nepal','ch':'China','us':'United States',}
  8. countries['np']
  9. countries.get('ch')
  10.  
  11. #methods in dictionaries
  12. dir(a)[-11:]
  13.  
  14. #
  15. b = a.fromkeys('rahul')
  16. b['r'] = 5
  17. print(b['r'])
  18.  
  19. OUTPUT : 5
  20.  
  21. #
Add Comment
Please, Sign In to add comment