Section: Practice Makes Perfect
Link to this part of the course: censor
I can't seem to get this figured out. I've perused the other posts but it's just not clicking. I've posted my code below, but I keep getting the following error:
Oops, try again. Your function fails on censor("hey hey hey","hey"). It returns "hey hey hey *** *** " when it should return " *** ***".
So I've done something right if it's doing the "*** *** ***" part, but how do I get rid of the first 3 "hey"s????
def censor(text, word): new_txt = text.split(" ") for i in new_txt: if i == word: new_word = "*" * len(word) new_txt.append(new_word) return " ".join(new_txt)