title: Looking for a key in a nested dict to change the type of the key
body: <p>I have a dict like this one:</p>
  
  <pre><code>exampleDict={'name': 'Example1', 'code': 2, 'price': 23, 'dimensions': [2,2]}
  </code></pre>
  
  <p>And I want to change the type of <code>dimensions</code>to a string, like this: </p>
  
  <pre><code>exampleDict['dimensions'] = str(dict['dimensions'])
  </code></pre>
  
  <p>This works just fine. But imagine there are nested dicts inside my <code>exampleDict</code>, and <code>dimensions</code>is a bit far inside. </p>
  
  <p>My guess is to do something recursively. From what I have searched in here, (examples like <a href="https://stackoverflow.com/questions/10756427/loop-through-all-nested-dictionary-values">this one</a>, or <a href="https://stackoverflow.com/questions/39233973/get-all-keys-of-a-nested-dictionary">this one</a>, they use <code>yield</code>in a recursive function, but I am not sure why it's used. </p>
  
  <p>I was thinking on doing this:</p>
  
  <pre><code>def changeToStringDim(d):
      if 'dimensions' in d:
          d['dimensiones'] = str(d['dimensions'])
      for k in d:
          if isinstance(d[k], list):
              for i in d[k]:
                  for j in changeToStringDim(i):
                      j[dimensions] = str(j['dimensions'])
  </code></pre>
  
  <p>I found it in here, but instead of the assignment of <code>j[dimensions]=str(j['dimensions'])</code> it did a <code>yield</code>.But I adapted the solution to this, and it works fine in a dict like this example. </p>
  
  <p>Now I am trying to do it in a nested one. </p>
  
  <pre><code>exDict2={'name': 'example1',
           'nesting': {'subnesting1': 'sub2',
                       'coordinates': [41.6769705, 2.288154]},
           'price': 123123132}
           }
  </code></pre>
  
  <p>With the same function but changing it to coordinates:</p>
  
  <pre><code>def changeToStringCoord(d):
      if 'coordinates' in d:
          d['coordinates'] = str(d['coordinates'])
      for k in d:
          if isinstance(d[k], list):
              for i in d[k]:
                  for j in changeToStringDim(i):
                      j['coordinates'] = str(j['coordinates'])
  </code></pre>
  
  <p>And it won't do anything. I have debugged it, and it will just go through <code>name</code>, <code>nesting</code>and  <code>price</code>. The <code>isinstance</code>is not working properly (or it is and I am not fully understanding its methodology). </p>