get value from dictionary with default value : Get : Dictionary PYTHON TUTORIALS


PYTHON TUTORIALS » Dictionary » Get »

 

get value from dictionary with default value


d2 = {'spam': 2'ham': 1'eggs': 3}         # Make a dictionary

print d2.get('spam' )                           # A key that is there
print d2.get('toast')                           # A key that is missing
print d2.get('toast', 88)



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Dictionary
» Get