title: Zip lines in a file with a list and iterate
body: <p>I want to create a dictionary where the keys are taken from a list <code>keys</code> and the values are lists of lines taken from multiple text files. Let's assume the list <code>keys</code> and all the files to be read have the same number of lines.</p>
  
  <p>How can I iterate over the list <code>keys</code> and the lines of each file simultaneously? My idea is to use <code>zip()</code> but that hasn't worked for me.</p>
  
  <p>I know that I can iterate over lines in a file using:</p>
  
  <pre><code>currFile = open('myfile.txt', 'r')
  for line in currFile:
      # Do something
  </code></pre>
  
  <p>And I know that I can iterate over two lists simultaneously with:</p>
  
  <pre><code>for foo, bar in zip(foos, bars):
      # Do something
  </code></pre>
  
  <p>But this doesn't work:</p>
  
  <pre><code>myDict = {}
  keys = [17, 21, 8, 2, ..., 91]
  currFile = open('myfile.txt', 'r')
  for key, line in zip(keys, currFile):
      myDict[key] = line
  </code></pre>
  
  <p>I could pull all the lines in the file out into a list, zip it, and then run the loop, but that wouldn't be very efficient.</p>
  
  <p>How can I iterate over the list <code>keys</code> and lines in a file simultaneously so that zip() gets called dynamically?</p>