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

I am trying to access text's indices that have word in them and store the indices in d.


Replace this line with your code. 
def censor(text, word):
    l = len(word)
    text.split()
    
    for c in text:
        d = text.index(c)
        if c == word:
            text[d] = l * "*"
    return " ".join(text)


#2

Just spotted another huge issue. text.split() needs to be assigned.

words = text.split(" ")     # the default is okay, though

Now you should be able to get an index the way you did to begin with.

Update:

def censer(sentence, term):
    words = sentence.split()
    for word in words:
        if word == term:
            words[words.index(word)] = len(term) * "*"
    return " ".join(words)
print censer("hey hey hey","hey")