Censor


#1



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


def censor(text,word):
    y = []
    for x in text:
        if x in word:
            y.append('*')
        else:
            y.append(x)
    return ''.join(y)

Error Message:
Oops, try again. Your function fails on censor("Yo go fro yo go","go"). It returns "Y* * fr y* **" when it should return "Yo ** fro yo **".


Think it should replace the word with * but it seems to have some bug here.Please help here.
I know i should use split() Method,I just want to make it more concise.


Replace this line with your code.


#2

Oh,I kind of realize what wrong with the code.......it replace all 'g' and 'o' character with '*'.So I eventually need to use split() method.


#3

The method is very like the same method in Javascript.


#4

did you solve the problem? If not, could you post an updated version of your code so we can help you further (if you want)?


#5

I have soved.Thanks for asking!


#6