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

It should return "*** *** ***".

Replace this line with your code. 
def censor(text,word):
    for i in t:
        if i==word:
            o=len(word) * "*"
    return result


For this exercise we do not need to modify the inputs. What if the word has a capital letter in it?

This will return a line of text with no white space. There should be spaces in the text just as there were in the input. Instead of using a string to accumulate the censored text, try using a list, then join with a space separator.


better use string replace method here


Not really advisable. That method has not come up yet (in the first set of units). Better to use what we know for this one.


what should i do now?
how can i solve this?


You have the steps in place, just change your working variable to a list and append either len(word) * "*" or 'term'.

censored = []
for term in text:
    if term == word:

 return " ".join(censored)


It's done with your advice

Thanks a lot!!!:grinning:


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