get values in dictionary python code example
Example 1: how to get element from dictionary python
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
dict['Age'] = 8;
dict['School'] = "DPS School";
print "dict['Age']: ", dict['Age']
print "dict['School']: ", dict['School']
Example 2: how to get value from key dict in python
dictionary = {1:"Bob", 2:"Alice", 3:"Jack"}
entry = dictionary[2]
Example 3: python dictionary get value
dict = {'Name': 'Zabra', 'Age': 7}
print "Value : %s" % dict.get('Age')
print "Value : %s" % dict.get('Education', "Never")