Censor


#1



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


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 "*** *** ***".


Help please! I'm stuck. I've checked other posts and I can't figure out why this is not working. Your help is highly appreciated!


def censor(text, word):
    text.split()
    new = []
    for string in text:
        if string == word:
            string = "*" * len(string)
            new.append(string)
        else:
            new.append(string)
    text = " ".join(new)
    return text
    print text


#2

here:

text.split()

you split text, but don't store the result of this split action in a variable? so when you start looping, text is still a string


#3

Oohh got it! Thank you so much!


#4