Censor - Why is my code wrong?


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


Can somebody please explain why is the site marking my code as wrong because when I run it in an interpreter it works good.

def censor(text, word):
    t = text.split(word)
    w = len(word) * "*"
    final = w.join(t)
    print final


you print final instead of returning it (use the return keyword)

i like your solution, really clever :slight_smile:


Thanx! Such a stupid mistake :slight_smile:
Thanx again!



I, too, think that solution is clever. However, there is a minor glitch in it, even after print is changed to return. The SCT does not catch the glitch, though.

Try this function call ...

print censor("a stitch in time saves nine", "in")



@amy313 posting answers without explanation is not according to the guidelines


ok, i will follow your advice.