Censor


#1

def censor(text, word):
    list = text.split()
    for i in range(len(list)):
        index = list.index(word)
        if str(index).isdigit() == True:
            list.remove(word)
            list.insert(index, "*" * len(word))
        else:
            i += 1
    " ".join(list)
    return text

Oops, try again. Your code looks a bit off--it threw a "'spam' is not in list" error. Check the Hint if you need help!


#2

Did you mean to write,

return " ".join(list)

?


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.