Page 8 - Lesson Note - DICTIONARIES
P. 8
update()
• to merge two dictionaries
• it merges the keys and values of one dictionary into another and overwrites values of
same key
setdefault() method
Inserts a new key:value pair into the dictionary only if the key doesn’t exist.
If key exists, it returns the value of corresponding key.
copy()
Returns a shallow copy of the dictionary. The shallow copy doesn’t modify the original
string.
Syntax: dict.copy()