I see this is in console: ( which looks right)

this **** is wack ****


I see an error:

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

Here is my solution:

def censor(text, word):
    words = text.split()
    for i in range(len(words)):
        if words[i] == word:
            words[i] = len(word) * '*'
    print ' '.join(words)
censor("this hack is wack hack", "hack")
censor("hey hey hey", "hey")

See output in console window: which looks right.


Instead of printing, try return.


Yes, that did the trick :slight_smile:

thank you!


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