Docsity

Python dictionary methods, Summaries of Programming Languages

Toggle sidebar
bg1
MethodDescription
Clear() Removes all the elements from the dictionary
Copy() Returns a copy of the dictionary
Fromkeys() Returns a dictionary with the specified keys and value
Get() Returns the value of the specified key
Items() Returns a list containing 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

Partial preview of the text

Download Python dictionary methods and more Summaries Programming Languages in PDF only on Docsity!

MethodDescription Clear() Removes all the elements from the dictionary Copy() Returns a copy of the dictionary Fromkeys() Returns a dictionary with the specified keys and value Get() Returns the value of the specified key Items() Returns a list containing 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