Oops, try again. Your function fails on censor("hey hey hey","hey"). It returns "h e y h e y h e y" when it should return "*** *** ***".
I am trying to access text's indices that have word in them and store the indices in d.
Replace this line with your code. def censor(text, word): l = len(word) text.split() for c in text: d = text.index(c) if c == word: text[d] = l * "*" return " ".join(text)