Python Dictionary Methods
Python Dictionary is like a map that is used to store data in the form of a key:value pair. Python provides various in-built functions to deal with dictionaries. In this article, we will see a list of all the functions provided by Python to work with dictionaries.
Table of Python Dictionary Methods
Functions Name | Description |
---|---|
clear() | Removes all items from the dictionary |
copy() | Returns a shallow copy of the dictionary |
fromkeys() | Creates a dictionary from the given sequence |
get() | Returns the value for the given key |
items() | Return the list with all dictionary keys with values |
keys() | Returns a view object that displays a list of all the keys in the dictionary in order of insertion |
pop() | Returns and removes the element with the given key |
popitem() | Returns and removes the key-value pair from the dictionary |
setdefault() | Returns the value of a key if the key is in the dictionary else inserts the key with a value to the dictionary |
update() | Updates the dictionary with the elements from another dictionary |
values() | Returns a list of all the values available in a given dictionary |
Note: For more information on Python Dictionary refer to Python Dictionary Tutorial.
Please Login to comment...