def censor(text,word):
    text = str(text)
    word = str(word)
    Text=text.split(" ")
    for n in Text:
        if n not in Word:
    return Kero

text = raw_input("text?\n")
word = raw_input("word?\n")    
print  censor(text,word)

Please help me,i can’t fix it


Kero is a list:


if you want to add items to a list, i would use append:


Now, the variable you want to append is n, n contains the words, if you where to have this code:

for n in Text:
   print n

The words would be printed, so you can just append n, no need to do Text[n]
This goes for both the if and else condition.

Now, you result is a list, so you might want to use .join to convert it to a string at the end.


Thx,i forgot Kero is list


Well, you can also make kero a string, then you can do:

Kero = Kero + n

but this represents a problem, you would have to include the spaces somewhere (since you removed them)

Did you resolve the issue? If you need more help, post an updated version of your code with error message and question