the code works fine, but i’m getting an error:

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

def censor(text,word):
    new_text = ""
    for x in text.split():
        if word in text:
            new_text = text.replace(word,"*" * len(word))
    print new_text  
censor("hey hey hey","hey")


your function only prints the censored string, it doesn’t return the censored string


You have to add “return new_text” to end of the function.


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