title: Why its showing key error when i am using setdefault method?
body: <p>I am using setdefault method and following this tutorial: <a href="https://jeffknupp.com/blog/2013/02/14/drastically-improve-your-python-understanding-pythons-execution-model/" rel="nofollow">This tutorial </a></p>
  
  <p>Here a example which is :</p>
  
  <pre><code>my_string = 'abc'
  tree = {}
  def add_to_tree(root, value_string):
  
  
  
      for character in value_string:
          root = root.setdefault(character, {})
          print(tree['a']['b'])
  
  
  add_to_tree(tree, my_string)
  </code></pre>
  
  <p>Why its showing key error when i am using setdefault ? </p>
  
  <p>edit: I got the error but please explain how this code is working?</p>