I am trying to get to speed on the use of dictionaries. I spent three hours last night searching the web for examples similar to some of the things I am trying to do. For example, suppose I have two dictionaries (actually I have two lists of dictionaries).
d1={key1:1, key2:2}
d2={key1:1, key2:'A', key4:4}
I want to update d1 so it looks like the following:
d1={key1:1, key2:[2,'A'], key3:3, key4:4}
Ii can't seem to find adequate examples to get me started. I have a fair number of books and I also reviewed them but they all seem to have the same type of examples that I am finding on the web.
Does anyone know of a place or a book that has explicit examples and descriptions of how to use dictionaries?
I think one of the problems I am having is that I am not understanding how references are maintained as I access the dictionary.
I can check to see if the two dictionaries have a common key:
for k in d1.keys():
for k2 in d2.keys():
if k==k2:
print 'true'
but if they do I can't seem to combine the values into a list.
More than a direct answer to this particular example I would appreciate any suggestions about places where there are good examples of using dictionaries.