I'm not sure how to link the exercise, but the instructions are:
Write a function called censor that takes two strings, text and word, as input. It should return the text with the word you chose replaced with asterisks.
Unfortunately it gives the error:
Oops, try again. Your function fails on censor("Yo go fro yo go","go"). It returns "Yo ** fro yo go" when it should return "Yo ** fro yo **".
Why does my code not replace the second go in that sentence?
def censor(text, word): words = text.split() l = len(word) for i in range(l): if words[i] == word: words[i] = "*" * l return ' '.join(words)