Hello everyone. I would greatly appreciate if someone could explain to me why my code does not work and how I should modify it. Thank you!

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

def censor(text,word):
    text_list = text.split(" ")
    word_len = len (word)
    stars = "*" * word_len
    for i in range(len(text_list)):
        if text_list[i] == word:
            text_list[i] = stars
        print " ".join(text_list)


should be,

word_len = len(word)


I removed the spacing but the same error message still appears.


Your error message mentions a lack of return value. How do you return a value from a function?


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