-6

My objective is to print out all available files that end in '.txt' inside a folder, I'm unsure how to do so. Thank you for reading.

1 Answers1

0

you can use

filename.endswith('.txt')

simply just open the folder by

fileList = os.listdir("folder_path")  #open that folder 
for filename in fileList:
    if(filename.endswith('.txt')):  # check its extension
         print(filename)
Rishabh Jhalani
  • 1,049
  • 13
  • 22