title: Trying to get a list of all files in a given directory with a for-loop in Python 3
body: <p>I am new to programming and am trying to filter out all the files in a directory (= excluding the sub-directories) with Python 3. </p>
  
  <p>My test directory contains 3 PDF files and 2 subfolders, which contain other files. I want to get a Python list containing only the 3 PDF files.</p>
  
  <p>My code (apart from the necessary imports) currently looks like this:</p>
  
  <pre><code>folder_content = listdir(TESTDIRECTORY)
  file_list = []
  for item in folder_content:
      if path.isfile(item):
          file_list.append(item)
      else:
          pass
  print(file_list)
  </code></pre>
  
  <p>Unfortunatelly this only gives me an empty list: [] </p>
  
  <p>Why?</p>