In [4]:
dictionary = {'key1':'val1' , 'key2':'val2' , 'key3':'val3'}
print 'Value at key1 is: {x}'.format(x = dictionary['key1'])
In [17]:
myDictionary = {}
myDictionary['k1'] = 10
myDictionary['k2'] = 15.3
myDictionary['k3'] = 'Hello'
myDictionary['k4'] = [1,2,3]
print 'Value at k1 is: {x}'.format(x = myDictionary['k1'])
print 'First character of value at key k3 is : {x}'.format(x = myDictionary['k3'][0])
In [11]:
print 'content of My dictionary is: {x}'.format(x = myDictionary.items())
In [18]:
print 'Keys of My disctioary is: {x}'.format(x = myDictionary.keys())
print 'Values of My disctioary is: {x}'.format(x = myDictionary.values())
In [13]:
#remove element from disctionary
myDictionary = {'k1':10, 'k2':15.3, 'k3':'Hello', 'k4': [1,2,3]}
myDictionary.pop('k1')
print 'my dictionary after removing element at key k1 is: {x}'.format(x = myDictionary)
In [ ]: