Oops, try again. Does your censor function take exactly two arguments, a text string and a word to replace with asterisks? Your code threw a "'builtin_function_or_method' object is not iterable" error.

I am not iterating any in-built function. Why am I getting this error?

def censor(text,word):
    for item in text_list:
        if item==word:
            item="*"* len(item)
    return "".join(text_list)




split() is a method, so it requires parentheses

item will give you read only values from the list, any changes made to item won't persist


I am getting the following error:
Oops, try again. Your function fails on censor("Yo go fro yo go","go"). It returns "** ** fro yo go" when it should return "Yo ** fro yo **".

Where is it code execution failing? Please help.


n has no way of knowing of its the right index to replace a word in the sentence

If you want to do this, use range() in the for loop to retrieve index values


I got it right by using the below code. Thank you!


impressive, i gave one small hint and you instantly solved it.


I am a beginner in programming, your hints(without giving away the solution directly) help me a lot.


many people would struggle with the hints, so that you can solve the exercise using my obscure hints is something you should be proud of :slight_smile:


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