,12,11,10,20]
3
present in a text file "STORY.TXT".
If the "STORY.TXT" contents are as follows:
My first book
was Me and
My Family. It
gave me
chance to be
Known to the
world.
The
The output of the function should be:
Count of Me/My in file: 4
Write a function in Python that counts the number of "Me" or "My words
Answers
Answered by
14
Answer:
def count():
file = open("story.txt", 'r')
read = file.read()
split = read.split()
co = 0
for words in split:
if words in ["Me", "me", "My", "my"]:
co = co+1
print("Count of Me/My in file:", co)
count()
Explanation:
Similar questions