10.15


#1

def censor(text,word):
    text = str(text)
    word = str(word)
    Text=text.split(" ")
    Word=[str(word)]
    Kero=[]
    for n in Text:
        if n not in Word:
            Kero=Kero+Text[n]
        else:
            Kero=Kero+"*"*len(Text[n])
    return Kero

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

Please help me,i can't fix it


#2

Kero is a list:

Kero=[]

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

Kero.append(variable_you_want_to_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.


#3

Thx,i forgot Kero is list


#4

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