Correct answer, Codecademy says it's wrong...why?

I’ve gotten this quiz question a couple of times and can’t figure out why my answer is not correct (screenshot below). Thanks in advance for your help!

Your function prints the amount of words – it does not return it as the instructions demand.

2 Likes

Do note that the specifications state

… and returns a count of the words in the string that start with the uppercase or lowercase letter, M.

You may want to test your program on your computer or in an online interpreter.

Write different test cases for which you already know the answer. Pass these strings as arguments to your function and see whether you get the correct output.

If necessary, write a few print statements for debugging purpose at different points in your code. See if your loops are iterating over the right thing and that your intended logic is being implemented correctly at each step.

Once you are satisfied that your code meets all specifications, then submit your answer.

3 Likes