Home >>Python Dictionary Methods
Python dictionary is a collection of key/value pairs. Python has multiple methods to work in dictionaries. Through this reference tutorial page, you will get all the methods related to dictionaries.
Method | Description |
---|---|
clear() | It is used to removes all the elements from the dictionary. |
copy() | It is used to return a copy of the dictionary. |
fromkeys() | It is used to return a dictionary with the specified keys and value. |
get() | It is used to return the value of the specified key. |
items() | It is used to return a list containing a tuple for each key value pair. |
keys() | It is used to return a list containing the dictionary's keys. |
pop() | It is used to remove the element with the specified key. |
popitem() | It is used to remove the last inserted key-value pair. |
setdefault() | It is used to return the value of the specified key. If the key does not exist then insert the key, with the specified value. |
update() | It is used to update the dictionary with the specified key-value pairs. |
values() | It is used to return a list of all the values in the dictionary. |
Learn more about Python dictionaries Python dictionaries