10. censor


#1




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


According to the console, my code is performing correctly, but the error message is telling me its failing. The only thing I can think of is that the exercise wants me to use the split function?


def censor(text, word):
    n = len(str(word))
    text = text.replace(word, "*" * n)
    print text

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


#2

It's right. There is no return command in your code, just a print one. Maybe you should return text?
The intstructions are pretty tricky :slight_smile:
They're really not, it just has specific tests.


#3

Of course it is, such a rookie error!

Thank you. Clearly time for bed!


#4

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