First, change name of your
for variable name. By choosing
word you are overriding param name, so you can't use it in
for loop. Change it's name to
censored or something else.
Second, you are using compare operator
== instead of assigning
Variable used in this
for loop can be used to read value, but I think it can't be used to change it's value. You should change list items directly in list.
You can use this loop to find index of word:
for index, word in enumerate(text):
word == censored, if
True then you can use
index variable to change list item value
text[index] = '*' * len(word)
Also, check if your function is case-insensitive.