← back to unit
Easy
# searching easy
How Many Times Does the Word Appear?
The parrot learned one favorite word and sprinkles it into every sentence. 🦜
You get a list of words the parrot squawked and the favorite word. Count how many times the favorite appears and print the count.
Example:
Input: words = ["hello", "cracker", "hello", "ship", "hello"], favorite = "hello"
Output: 3
hello shows up at positions 0, 2, and 4 — that's 3 matches.
💡 need a hint?
srch-word-appears.py🔒 given lines are locked — write your code in between
loading...