title: How to extract the key values from a function within a function?
body: <p>I have data about the movies in the format of the dictionary, like the example below:</p>
  
  <pre><code> {'Similar': {'Info': [{'Name': 'Tony Bennett', 'Type': 'music'}], 'Results': [{'Name': 'The Startup Kids', 'Type': 'movie'}, {'Name': 'Charlie Chaplin', 'Type': 'movie'}, {'Name': 'Venus In Fur', 'Type': 'movie'}, {'Name': 'Loving', 'Type': 'movie'}, {'Name': 'The African Queen', 'Type': 'movie'}]}}
  </code></pre>
  
  <p>I need to extract movie names from that, but I am getting different errors on the go. Have been trying many things, but haven't found a solution. </p>
  
  <p>I created the function get_movies_from_tastedive(movies), to have my data on movies from TasteDive (Part 1) and then I defined a second function, (Part 2) extract_movie_titles for getting the movie titles. </p>
  
  <p>Getting a KeyError: KeyError: Similar on line 23 
  - I am running it in runestone learning environment and it also shows: {'error': 'Response not interpretable as json. Try printing the .text attribute'}. 
  - If I try to print .text it says that AttributeError: 'dict' object has no attribute 'text' on line 21</p>
  
  <h1>Part 1</h1>
  
  <pre><code>def get_movies_from_tastedive(movies):
      baseurl = "https://tastedive.com/api/similar"
      params_diction = {}
      params_diction["q"] = movies
      params_diction["type"] = "movies"
      params_diction["limit"] = 5 
      movie_resp = requests_with_caching.get(baseurl, params = params_diction)
      #print(movie_resp.json())
      return movie_resp.json()
  </code></pre>
  
  <h1>Part 2</h1>
  
  <pre><code>def extract_movie_titles(movies):
      t = get_movies_from_tastedive(movies) 
      #title = t.text
      #print(title)
      return [d['Name'] for d in t['Similar']['Info']]
  
  
  extract_movie_titles(get_movies_from_tastedive("Tony Bennett"))
  extract_movie_titles(get_movies_from_tastedive("Bridesmaids"))
  </code></pre>
  
  <p>The expected result should be: ['The Startup Kids', 'Charlie Chaplin’], ‘Venus In Fur’, ‘Loving’, ‘The African Queen’] but getting a KeyError: Similar on line 23</p>