using python
>>> stringCount('example.txt', 'line')
4
def stringCount(file_name, word):
f = open(file_name)
r = f.read().split()
c = 0
for one in r:
if one == word:
c += 1
f.close()
return c
print(stringCount('example.txt', 'line'))
# Hit the thumbs up if you are fine with the answer. Happy Learning!
Get Answers For Free
Most questions answered within 1 hours.