Python Dictionary Methods

Method NameMethod Description
dict.clear()Removes all elements from the dictionary
dict.copy()Creates a shallow copy of the dictionary
dict.fromkeys()Create a new dictionary from a given iterable of keys
dict.get()Returns value associated with a key, or default value if key does not exist
dict.items()Outputs a list of (key, value) tuple pairs of the dictionary
dict.keys()Outputs all the keys of a dictionary as a dict_keys() iterable object.
dict.pop()Removes and returns a specified (key-value) pair element from a dictionary.
dict.popitem()Removes and returns the last (key-value) pair element that was inserted in the dictionary.
dict.setdefault()Returns the value associated with the passed key.
dict.update()Updates a dictionary with a (key-value) pair element from another dictionary, or from an iterable of (key-value) pair elements.
dict.values()Returns an iterable dictionary view object of all the values in a dictionary.