title: Modifying keys and values in nested dictionaries in python
body: <p>I'm working with a nested dictionary and I'm trying to figure out how to modify certain nested and non-nested keys/values effectively. In short, I'm trying to do the following:</p>
  
  <ol>
  <li>take a nested value and switch it with a non-nested key</li>
  <li>rename a nested key.</li>
  </ol>
  
  <p>Here's a basic example of a dictionary that I'm working with:</p>
  
  <pre><code>pet_dictionary = {'Buford':{'color':'white', 'weight': 95, 'age':'3', 
                    'breed':'bulldog'}, 
                    'Henley':{'color':'blue', 'weight': 70, 'age':'2', 
                    'breed':'bulldog'}, 
                    'Emi':{'color':'lilac', 'weight': 65, 'age':'1', 
                    'breed':'bulldog'}, 
                    }
  </code></pre>
  
  <p>I want to take the non-nested key, which is name of each dog (i.e. Buford, Henley, Emi), switch it with nested value for the age (i.e. 3, 2, 1), and then change the nested key name from 'age' to 'name.' So the output should look like this:</p>
  
  <pre><code>pet_dictionary = {'3':{'color':'white', 'weight': 95, 'name':'Buford', 
                    'breed':'bulldog'}, 
                    '2':{'color':'blue', 'weight': 70, 'name':'Henley', 
                    'breed':'bulldog'}, 
                    '1':{'color':'lilac', 'weight': 65, 'name':'Emi', 
                    'breed':'bulldog'}, 
                    }
  </code></pre>
  
  <p>I understand how to do this manually one-by-one, but I'm not sure what the best approach is for making all of these changes in a more elegant/optimal way.</p>