This is what I would like it to do.
Enter the search file to look in April_hours
Enter your search item 50 150
#example of text in document
April1, 50 100 150 75 200
April2, 100 150 200 75 250
April3, 50 75 100 150 200
2 of your search was found
I have been working on it and it is working partially. Although I can not get it to count them as a group in the same line yet. I am trying to go line by line now to check for the group with a while loop, so if all are in the line it will add to the count and if any one of them are not then it will go to the next line. I haven't decided if this is the best way I can do it or not.
The code dosn't have the readline() and loop because I have not been able to make it work.
If anyone can help please let me know if I am going about this the correct way.
Enter the search file to look in April_hours
Enter your search item 50 150
#example of text in document
April1, 50 100 150 75 200
April2, 100 150 200 75 250
April3, 50 75 100 150 200
2 of your search was found
I have been working on it and it is working partially. Although I can not get it to count them as a group in the same line yet. I am trying to go line by line now to check for the group with a while loop, so if all are in the line it will add to the count and if any one of them are not then it will go to the next line. I haven't decided if this is the best way I can do it or not.
The code dosn't have the readline() and loop because I have not been able to make it work.
If anyone can help please let me know if I am going about this the correct way.
Code:
look_in = raw_input ("Enter the search file to look in ")
search_terms = raw_input ("Enter your search item ").split() # Note the final ()
data = open(look_in).read()
count = 0
for term in search_terms:
count += data.count(term)
if count:
print count
else: print "Your search was not found"
Comment