Https://www.codecademy.com/es/courses/learn-python/lessons/practice-makes-perfect/exercises/censor-?action=resume_content_item


#1

Hello i wanna know why i got an error, thanks for the help.

def censor(text,word):
  wordlen = len(word)
  textlist = text.split()
  string = [] 
  
  for t in textlist: 
    if t == word:
      t = '*' * wordlen 
      string.append(t)
      False
    else:
      string.append(t)
  return ' '.join(string)

#2

That looks like a stray token.

Know that t is immutable in this instance so we can not alter it in the loop.

When choosing a variable name, be sure it relates to what it references. This may become a string in the return value, but it is still a in working form.

result = []

would be indicative of a working variable that is a list.

for t in textlist: 
    if t == word:
      result.append('*' * wordlen)
    else:
      result.append(t)

and we would return,

return ' '.join(result)

#3

Thanks for the information, you make my code small, thats great