title: Reading multiple lines of strings into a list - Python
body: <p>I have a code that outputs all of the files that are a .pdf in a directory. It outputs a stack of strings like below.</p>
  
  <pre><code>file0.PDF
  file1.PDF
  file2.PDF
  file3.PDF
  </code></pre>
  
  <p>I want to put these strings into a list, that looks like this:</p>
  
  <pre><code>['file0.PDF', 'file1.PDF', 'file2.PDF', 'file3.PDF']
  </code></pre>
  
  <p>I have managed to do this with the code below.</p>
  
  <pre><code>import os 
  
  list_final = []
  for file in os.listdir(path):
      if ".PDF" in file:
          for value in file.split('\n'):
              list_final.append(value)
  print(list_final)
  </code></pre>
  
  <p>This gives the list in the format above, which is what I want.</p>
  
  <p><strong>Is there a better way to do this?</strong> I feel that my code is very inefficient. I have tried through a list comprehensions such as the below but I am unsure why it does not work.</p>
  
  <pre><code>list_final = [value for value in file.split('\n')]
  </code></pre>
  
  <p>Thanks in advance.</p>