title: searching inside dictionaries in Python
body: <p>I'm working with python an a dictionaries that I have not able to solve it. I'm working with a dictionaries. I'm trying search every element of the the dictionary <code>words</code> inside all medias.items() and then four print it out lines, two for <code>medias[0]</code> and two for <code>medias[1]</code>. Is there something I made wrong? Any idea to fix it? Thanks in advance.</p>
  <pre><code>import requests
  import time
  from bs4 import BeautifulSoup
  
  headers = {
      'user-agent': &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36&quot;}
  
  
  def count_words(url, the_word):
      r = requests.get(url, headers=headers)
      return r.text.lower().count(the_word)
  
  def main():
    #  url = 'https://www.nytimes.com/'
      medias = {
          'Los Angeles Times': ['http://www.latimes.com/'],
          'New York Times': ['http://www.nytimes.com/']
      }
  
      word = 'trump'
      words = ['Trump', 'Facebook']
  
      print('--- Iniciando ---')
      print('Hora: ', time.strftime(&quot;%X&quot;))
      for web_name, urls in medias.items():
          for url in urls:
              count = count_words(url, words)
              print('La palabra {} aparece {} veces en el sitio del {}.'.format(words, count, web_name))
  
  if __name__ == '__main__':
      main()
  </code></pre>