Help with 15.10 : Censor


#1


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


def censor(text,word):
    lst = text.split()
    for i in range(0, len(lst) - 1):
        if lst[i] == word:
            lst[i] = len(word) * '*'
    return ' '.join(lst)


#2

You're doing one iteration too few
https://docs.python.org/2/library/functions.html#range


#3

try this

for i in range(0, len(lst) ):


#4

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