Skip to content

Instantly share code, notes, and snippets.

@MishraKhushbu
Created September 5, 2019 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MishraKhushbu/7836b0b29741d1413d546e3b4928383b to your computer and use it in GitHub Desktop.
Save MishraKhushbu/7836b0b29741d1413d546e3b4928383b to your computer and use it in GitHub Desktop.
PYTHON_DICTIONARY
Dictionary Methods
Python has a set of built-in methods that you can use on dictionaries.
url : https://www.w3schools.com/python/python_dictionaries.asp
Method Description
clear() ===>Removes all the elements from the dictionary e
copy() ====>Returns a copy of the dictionary
fromkeys()===>Returns a dictionary with the specified keys and values
get() ====>Returns the value of the specified key
items()====>Returns a list containing the a tuple for each key value pair
keys() ====>Returns a list containing the dictionary's keys
pop()=====>Removes the element with the specified key
popitem()====>Removes the last inserted key-value pair
setdefault()====>Returns the value of the specified key. If the key does not exist: insert the key, with the specified value
update()====>Updates the dictionary with the specified key-value pairs
values()====>Returns a list of all the values in the dictionary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment