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 "*** *** *** " 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:
            i="*"*len(i)
            out+=i + " "
            " ".join(out)
        else:
            out+=i+" "
    " ".join(out)        
    return out


#2

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


#4

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