title: Creating a dictionary while iterating through multiple for loops?
body: <p>I am storing the dates of Presidential speeches and each speech's respective <code>filename</code> in a dictionary. The <code>speeches</code> object looks like this:</p>
  
  <pre><code>[&lt;a href="/president/obama/speeches/speech-4427"&gt;Acceptance Speech at the Democratic National Convention (August 28, 2008)&lt;/a&gt;,
  &lt;a href="/president/obama/speeches/speech-4424"&gt;Remarks on Election Night (November 4, 2008)&lt;/a&gt;,...]
  </code></pre>
  
  <p>And <code>end_link</code> looks like:</p>
  
  <pre><code>['/president/obama/speeches/speech-4427', '/president/obama/speeches/speech-4424',...]
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>date_dict = {}
  for speech in speeches:
      text = speech.get_text(strip=True)
      date = text[text.index("(") + 1:text.rindex(")")]
      end_link = [tag.get('href') for tag in speeches if tag.get('href') is not None]
      for x in end_link:
          splitlink = x.split("/")
          president = splitlink[2]
          speech_num = splitlink[4]
          filename = "{0}_{1}".format(president,speech_num)
          if 2 == 2:
              f = date_dict['{0} {1}'.format(filename,date)]
  </code></pre>
  
  <p>I get the proper date output (e.g. <code>August 15, 1999</code>) and <code>filename</code> is fine. Now, I'm just trying to join the two and am getting the following error:</p>
  
  <pre><code>date_dict['{0} {1}'.format(filename,date)]
  KeyError: 'obama_speech-4427 August 28, 2008'
  </code></pre>
  
  <p>I don't really know where to go from here.</p>