AlphaCodingSkills

Python - Dictionary Methods


Advertisements

Previous Page Next Page

The Python has a number of methods and functions that are available for use with dictionaries. These methods and functions are listed below in alphabetical order. For more details about any one of these, please visit its page.

Dictionary Methods & Functions
MethodsDescription
clear() Deletes all elements of the dictionary
copy() Returns a copy of the dictionary
fromkeys() Creates a dictionary with specified keys and values
get() Returns value of the specified key
items() Returns a list of tuples with each key-value pair in tuple
keys() Returns a list of all keys of the dictionary
pop() Removes specified key-value pair of the dictionary
popitem() Removes the last key-value pair of the dictionary
setdefault() Checks specified key in the dictionary. If the key does not exist, it inserts the specified key with specified value
update() Updates the dictionary with the specified key-value pair(s)
values() Returns a list of all values of the dictionary
FunctionsDescription
len() Returns total number of elements in the dictionary
dict() Creates dictionary using an iterable object containing key-value pairs





Previous Page Next Page