Dict.update: To update element in dictionary dict.update is used.

a={'Indian':'Delhi','US':'Newyork'}
a.update({'China':'Beijing'})
a
Output:{'Indian': 'Delhi', 'US': 'Newyork', 'China': 'Bejing', 'Nepal': 'Kathmandu'}


Dict.pop
: To remove element using key in
dictionary dict.pop is used.

Syntax: dict.pop(‘key’,’d’)

Key:It will result key value if present in dictionary otherwise will return d.as shown below if key:’china’ not in given dict then it outputs ‘not in dict’.if key present in dict it will return corresponding value.

a.pop('china','not in dict')
Output:'not in dict'
a.pop('China','not in dict')
Output:'Bejing'

 

By SC