Python‎ > ‎dict‎ > ‎

dict.get()

http://www.adilwaseem.com/

Introduction 
The method returns with the corresponding value of key in dictionary. 

Syntax
dict.get(x)

Parameters
x=key

Examples
The method returns with the corresponding value of key.
 >>> dict={'Adil':3,'John':2,'Fen':1,'Din':4}
>>> dict.get('Adil')
3
>>> dict.get('Din')
4
>>> dict
{'Din': 4, 'John': 2, 'Adil': 3, 'Fen': 1}
>>>

Returns as:
 >>> x=dict({'VA':3.1, 'DC':2,'NY':5.1, 'CA':4.4})
>>> x.get('VA')
3.1
>>> x
{'VA': 3.1, 'DC': 2, 'NY': 5.1, 'CA': 4.4}
>>> 

Comments