Your function fails on censor("hey hey hey","hey"). It returns "hey hey hey" when it should return "*** *** ***".

I expected the code to rewrite the word I want censored, but it isn't happening

def censor(text, word) :
    txtlist = text.split()
    for wrd in txtlist :
        if wrd == "word" :
            txtlist[txtlist.index(wrd)] = "*" * len(wrd)
    return " ".join(txtlist)



if wrd == "word"

word should be a variable (to match the second function parameter), we want to be able to control which word is censored (by supplying a second argument to function)


Wow...it was so simple and I couldn't see it! Thanks