I am trying to get my python script to read a text file with a list of file names with extensions and print out when it finds a particular extension (.txt files to be exact). It
I guess you should add the endline sign \n at the end of the extension:
\n
with open ("file_list.txt", "r") as L: for line in L: if line.endswith(".txt\n"): print ("This has a .txt: " + line)