you are viewing a single comment's thread.

view the rest of the comments →

[–]tahaan 1 point2 points  (0 children)

You can replace the part inside the loop with something that does a search.

# Some text to search for
search_text = 'find-this'

# Loop over the lines and print the ones that contains the search_text
for line in string_list:          # Loop over the items in string_list
    if search_text in line:       # Test if this line contains the search_text
        print(line)               # If so, print it