10.censor


#1



whats wrong with my code?
def censor(text, word): 
    split = text.split(" ")
    new_text = ""
    for term in split:
        if term == word:
            term = "*" * len(word)
        new_text += term + " "
    return new_text


#2

you have an additional space at the end, for example with:

print censor("hey hey hey", "hey")

your function returns:

***_***_***_

i replaced the spaces with underscores, you could just slice it off? (new_text[:-1])


#3

tanks