title: initialising and incrementing nested dict python
body: <p>I am sorry if this has been asked elsewhere, but have been trying and googling all day to solve this to no avail.</p>
  <p>I wish to initialise an empty dict as such:</p>
  <p><code>empty_dict = {}</code></p>
  <p>Then, I take rows from a csv file, saved into a variable, lets say <code>saved_word_list</code>. In this <code>saved_word_list</code> are the rows from the csv file which contain sentences. Each of these sentences on the rows are identified as either <code>A</code> or <code>B</code>. What I would like to do is to populate the <code>empty_dict</code> with each unique word in the sentence so that each word is only counted once per line and added to the correct nested portion of the dict.</p>
  <p>An example:</p>
  <p><code>row_1 = {&quot;this is a fine day to do a lot of coding&quot;}</code></p>
  <p>This row would be labelled <code>A</code>, so our list would change to:</p>
  <p><code>empty_dict = {'this':{'A':1,'B':0}, 'is':{'A':1, 'B':0}, 'a':{'A':1, 'B':0}.....}</code></p>
  <p>So, below is as much as I have, but I would like to get to understanding how to reach the goal of the line above. Any ideas how I can get to this point?</p>
  <pre><code>for (sentence, label) in zip(saved_word_list, labels):
      keys = set(labels)
      values = set(sentence.split())
      for key in keys:
        for value in values:
          if value not in empty_Dict:
            empty_Dict[value][key] = value
          else:
            empty_Dict[value][key] += 1
  </code></pre>