Attributes of Dictionary

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

clear: Empties the dictionary of all key-value pairs.

copy: Returns a shallow copy of the dictionary.

keys: Returns a view object containing the keys of the dictionary.


values: Returns a view object containing the values of the dictionary.
items: Returns a view object of key-value tuple pairs in the dictionary.

get: Retrieves the value for a given key, or a default value if the key is
not present. .get( key )
pop: Removes and returns the value for a given key, or a default value if
the key is not present. .pop( key )
popitem: Removes and returns a random (key, value) pair from the
dictionary. .popitem()

fromkeys: Creates a new dictionary with keys from an iterable and a common
initial value.
setdefault: Retrieves the value for a given key or sets it to a default value
if not present. .setdefault( key )
update: Updates the dictionary with key-value pairs from another
dictionary or iterable.

You might also like