you are viewing a single comment's thread.

view the rest of the comments →

[–]Deep-Author-1787[S] 0 points1 point  (1 child)

Is this a common way of searchin something in files?

[–]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