Exercise for reference: 

Create a script that iterates through text files and checks if strings p, y, t, h, o, or n are found in the text file's content. If any of those strings is found, append that string to a list.

Answer: 

import glob

letters = []
file_list = glob.iglob("letters/*.txt")
check = "python"

for filename in file_list:
    with open(filename,"r") as file:
        letter = file.read().strip("\n")
    if letter in check:
        letters.append(letter)

print(letters)

Explanation:

The glob module here helps to generate a list of text files. Then we iterate through that list and read each file inside the loop, strip "\n" characters and then check if the letter extracted from the file is in the string "python," and we append that letter if it is.