title: Dictionaries in Python
body: <p>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).  </p>
  
  <pre><code>d1={key1:1, key2:2}
  d2={key1:1, key2:'A', key4:4}
  </code></pre>
  
  <p>I want to update d1 so it looks like the following:</p>
  
  <pre><code>d1={key1:1, key2:[2,'A'], key3:3, key4:4}
  </code></pre>
  
  <p>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.  </p>
  
  <p>Does anyone know of a place or a book that has explicit examples and descriptions of how to use dictionaries?  </p>
  
  <p>I think one of the problems I am having is that I am not understanding how references are maintained as I access the dictionary.  </p>
  
  <p>I can check to see if the two dictionaries have a common key:</p>
  
  <pre><code>for k in d1.keys():
      for k2 in d2.keys():
          if k==k2:
              print 'true'
  </code></pre>
  
  <p>but if they do I can't seem to combine the values into a list.</p>
  
  <p>More than a direct answer to this particular example I would appreciate any suggestions about places where there are good examples of using dictionaries.</p>