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

It says that it should return the same thing it says it did return

def censor (text,word):
    out = ""
    for i in text.split():
        if i == word:
            out+=i + " "
            " ".join(out)
            out+=i+" "
    " ".join(out)        
    return out


your sentence has an additional space at the end of the sentence, which you should remove (string slicing) or find a different approach to solve the problem


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