CENSOR (stuck, even after trying to find help here >.<)


def censor(text,word):
words = text.split()
new_words = []
for i in words:
if i == word:
new_words.append("*" * len(i))
" ".join(new_words)
return new_words

print censor("hey hey hey","hey")

the error it is giving me :

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

it seems like it is still printing out as a list. I need it to print as string, and I thought " ".join(new_words) would do the trick. apparently not. Thanks in advance!


should be, "*" * len(word) (but this is moot. i == word)

The issue is with this line...

It should read,

    return " ".join(new_words)


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