okay this is the question that ive got
write a function search_word(sentence, word)
that takes in two parameters. The function searches the sentence for that word and returns the number of occurrence which the word appears in it
Ive already tried all sorts, sorry im new to python and im tryna solve a problem statement however from the problem statement i dont get why
def search_word(sentence, word):
sentence = sentence.split()
count = 0
for words in sentence:
if word == words:
count += 1
return count
print(search_word("sunny rainy sunny windy", "sunny"))
the following outputs should show like this
>>>search_word("sunny rainy sunny windy", "sunny")
2
>>>search_word("school holiday is over", "weekend")
0
but what i got was
>>>search_word("sunny rainy sunny windy", "sunny")
1