title: Opening files from directory, and keeping file name and content
body: <p>I would like to read all files from a directory, and import both filename and content into a list. I wrote the following code, but it only imports only the last file in the directory.</p>
  
  <pre><code>import os
  
  fileList = []
  
  for dirname, dirnames, filenames in os.walk('.'):
      for filename in filenames:
          file = os.path.join(dirname, filename)
      f = open(file, 'r')
      contents = f.read()
      newItem = (file, contents)
      fileList.append(newItem)
  
  
  print(fileList)
  </code></pre>