1

I have a txt file. I wrote some code to search the file for 'Monday' and provided a counter to check how many times 'Monday' is found in the file.

I would like to ask the question 'what do you want to search for?' and allow the end user to input a word. Then, the code should find out how many times their desired word appears in the file.

print('what do you want to search for?')
name = input()
count=0
f=open('/Users/z007881/Documents/days.txt','r')
findit=f.readlines()
for line in findit:
if "input" in line:
    count=count+1
print (count)
f.close()
gmds
  • 17,927
  • 4
  • 26
  • 51
Jayne
  • 31
  • 2

0 Answers0