Censor


#1

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")

#2

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


#3

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


#4

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