Censor


#1



https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/1/4?curriculum_id=4f89dab3d788890003000096#


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)


#2

here:

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)


#3

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


#4