Censor - Why is my code wrong?


#1





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

Hello,

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


#2

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

i like your solution, really clever :slight_smile:


#3

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


#4

#5

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

#6

#10

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


#11

ok, i will follow your advice.