Counting Words in String

Hello, I am getting the output that it asks me to, but it still doesn’t like my code. I was wondering if someone could take a look and see where I am going wrong. These are the instructions.

  1. Go to you file.
  2. Take in the user input for the sentence and the query.
  3. Next, sanitize and format the input by removing the whitespace and converting it to lowercase.
  4. Count the occurrences of the substring.
  5. Print the results.

Hey Mayra,

Thanks for reaching out. The issue here is that your final print statement does not match the expected output. You have a typo in “occurences” and are missing the quotes around the searched word.

If you change your final line to:

print(f"There are {count} occurrences of '{word}' in the sentence.")

it will pass the check.

Let me know if you have any questions!