title: Recursively create a nested dictionary from string
body: <p>I have an issue that I've been trying to sort out. I have a string that needs to be converted to an nested dictionary with the keys and values based off the adjacent words in the string. Here is an example:</p>
  
  <pre><code>graphMaster = {}
  inputSentence = "I have a dog named Max."
  </code></pre>
  
  <p>I would like to take this string, and convert it into a dictionary resembling the output below:</p>
  
  <pre><code>print graphMaster
  {'I': {'have': {'a': {'dog': {'named': 'Max'}}}}}
  </code></pre>
  
  <p>I have tried the following:</p>
  
  <pre><code>graphMaster = {}
  inputSentence = "I have a dog named Max."
  while True:
      inputList = inputSentence.strip().split(' ')
      for currentIndex, word in enumerate(inputList):
          nextIndex = currentIndex + 1
          if nextIndex &lt; len(inputList):
              if word not in graphMaster.keys():
                  graphMaster[word] = inputList[nextIndex]
              elif word in graphMaster.keys():
                  break
  print graphMaster
  </code></pre>
  
  <p>I couldn't find a duplicate problem here and I pre-apologize if one exists that I couldn't find. Any help is greatly appreciated.</p>