Oops, try again. Your function fails on censor("hey hey hey","hey"). It returns "hey hey hey" when it should return "*** *** ***".
I think the line 6 would be the problem but I am not sure and I also have no idea how to rewrite.
def censor(text,word): list1 = text.split() stars = ("*" * len(word)) for indices in list1: if indices == word: indices = stars new_text = " ".join(list1) return new_text print censor("this hack is wack hack", "hack")