Error: Oops, try again. Your function fails on censor("hey hey hey","hey"). It returns "******" when it should return " *** ***".
I don't know how to make it right and Im not sure whether I can use my code or just think of a different solution, because it seems as if I was almost there, but maybe I'm just wrong. I guess the main problem is the "word_whole", it probably should not be there, but then the result would be "***" , that is only one word replaced(?) I don't understand why the "for loop" doesn't work for every word in the list.
Thanks for any advice!
def censor(text,word): text = text.lower( ) words = text.split(" ") for i in words: ln = len(i) word_ast = "*" * ln word_whole = word_ast * len(words) if i.isalpha(): return word_whole s = " " return s.join(words) return censor(text,word)