This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#File being in same directory as current program | |
with open('filename.txt') as f: | |
lines = f.read().splitlines() | |
print(len(lines)) | |
matching = [s for s in lines if "SearchString" in s] #return the list of lines with SearchString in it | |
if len(matching)==0: | |
print "Not found" | |
else: | |
print matching |