Dictionary: Get value by key : Dictionary get « Dictionary « Python






Dictionary: Get value by key

Dictionary: Get value by key
d2 = {'spam': 2, 'ham': 1, 'eggs': 3}    # make a dictionary

print d2                                       # order is scrambled

print d2.get('spam'), d2.get('toast'), d2.get('toast', 88)


           
       








Related examples in the same category

1.Dictionary get: default valueDictionary get: default value
2.Dictionary get valueDictionary get value