Help appreciated: Python 2, Practice makes perfect, censor

Im stuck on Python 2, Practice makes perfect, censor (10/15).

The forum post linked to in the exercise is locked.

We are tasked with creating a function that takes two arguments, a string and word, and we need to return the string except censoring out the word with the correct amount of stars representing each letter.

This is my code. Why won’t it let me pass and how can I fix it?


I imagine the issue might have to do with the spaces. Try just List[List.index(a)] = "*" * len(word) and then join with a space separator instead of an empty string using " ".join(List).

1 Like

That sounds very likely. I assume there’s a couple of background tests performed. What would happen in the original method @text2232328881 if the word to be censored was at the start or end of the text, or if say there were four words. What happens to the spaces?

Thank you very much. This was indeed the case :slight_smile: