Censor


#1



Oops, try again. Your function fails on censor("hey hey hey","hey"). It returns "['', '', '']" when it should return " *** ***".


My .join is not working correctly and I do not know why. Also, is there a more efficient/more right way to write this program? Any help is appreciated.


def censor(text,word):
    k = text.split()
    new = []
    loop = 0
    for t in k:
        if t == word:
            k[loop] = "*" * len(word)
            new.append(k[loop])
            loop = loop + 1
            
        else:
            new.append(k[loop])
            loop = loop + 1
    " ".join(new)
    return new
print censor("I like words","like")


#6