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

Shouldn't it go through all of the words and return the correct thing?

def censor(text, word):
    c = text.split(" ")
    b = len(word)
    censored = []
    for piece in c:
        if piece == word:
            return "*" * b 
            return piece
    s = "".strip()
    print s
print censor('hello there', 'there')


return terminates a function whenever a return occurs function ends at that moment.

can you think where does it happen in your function?

also you created a empty list named censored but you didnt' use it.make it useful.


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