title: Dynamically creating a dictionary in python
body: <p>I want to dynamically build a dictionary based on the string.</p>
  
  <p>I have 5 strings:</p>
  
  <pre><code>ABC
  ABC BCD DEF
  ABC BCD FGH
  ABC BCD FGH IJK
  ABC DEF GHI
  </code></pre>
  
  <p>I want to create this into a dict:</p>
  
  <pre><code>dict = {
   "ABC" : {
     "BCD": {"DEF": {}, "FGH":{IJK}},
     "DEF": {"GHI"},
    }
  }
  </code></pre>
  
  <p>This is what I have tried so far, but I'm not sure how to create the new key if there is a key error.</p>
  
  <pre><code># orgs = list of string from about
  for org in orgs:
      org_path_sp = org .strip().split()   
      org_cur = org_dict
      for org_el in org_path_sp:
          try:
              org_cur = org_cur[org_el.strip()]
  
          except KeyError:
              pass
              # create the new entry
  </code></pre>