Skip to content

Instantly share code, notes, and snippets.

@nake89
Created February 19, 2018 14:16
Show Gist options
  • Save nake89/2d26835f0f3985e169b3c1464b204761 to your computer and use it in GitHub Desktop.
Save nake89/2d26835f0f3985e169b3c1464b204761 to your computer and use it in GitHub Desktop.
searchinfile python function
def searchinfile(srchstr, filename):
with open(filename) as f:
wasd = 0
for line in f:
#print(line.lower(), end='')
tolwr = line.lower()
if srchstr in tolwr:
#print("found test in: " + line)
wasd += 1
print("Found " + str(wasd)+ " amount of " + srchstr + " in " + filename)
filezzz = "multiline.txt"
searchinfile("vege" ,filezzz)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment