Python method of deleting elements from dictionary

From , 3 Years ago, written in Python, viewed 144 times.
URL https://pastebin.vip/view/23e582ad
  1. # Create an empty dictionary
  2. d = {}
  3.  
  4. # Add an item
  5. d["name"] = "Fido"
  6. assert d.has_key("name")
  7.  
  8. # Delete the item
  9. del d["name"]
  10. assert not d.has_key("name")
  11.  
  12. # Add a couple of items
  13. d["name"] = "Fido"
  14. d["type"] = "Dog"
  15. assert len(d) == 2
  16.  
  17. # Remove all items
  18. d.clear()
  19. assert len(d) == 0
  20. #//python/8027

Reply to "Python method of deleting elements from dictionary"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website