Python‎ > ‎dict‎ > ‎

dict.update()

http://www.adilwaseem.com/

Introduction
The method returns with updating the values of the dictionary.

Syntax
dict.update(x)

Parameters
x=dictionary 

Examples
The method returns as:
 >>> a=dict({'Din': 4, 'John': 2, 'Adil': 3, 'Fen': 1})
>>> a.pop('Din')
4
>>> a.update()
>>> a
{'John': 2, 'Adil': 3, 'Fen': 1}
>>> a.popitem()
('John', 2)
>>> a.update()
>>> a
{'Adil': 3, 'Fen': 1}
>>>

The method update the dictionary.
 >>> x=dict({'VA':3.1, 'DC':2,'NY':5.1, 'CA':4.4})
>>> x.update()
>>> x
{'VA': 3.1, 'DC': 2, 'NY': 5.1, 'CA': 4.4}
>>> x.pop('VA')
3.1
>>> x.update()
>>> x
{'DC': 2, 'NY': 5.1, 'CA': 4.4}
>>> x.pop('NY')
5.1
>>> x.update()
>>> x
{'DC': 2, 'CA': 4.4}
>>>

Comments