4. Write a function in Python to read lines from a text file "notes.txt", to find and display the
occurrence of the word "the".
Answers
Answered by
1
def count(file, word):
from os import path, sys
from collections import Counter
if path.isfile("notes.txt"):
with open("notes.txt", 'r') as notes:
return Counter(notes.read( ).lower( ).split( )).get(word)
else:
print("Some files seem to be missing...")
sys.exit( )
Similar questions