10/15 Censor - replacing word


#1

I’m struggling to understand why my code doesn’t replace the word with stars…can anyone help?

def censor(text, word):
  new_text = text.split()
  star = "*" * len(word)
  for i in range(0,len(new_text)-1):
    if new_text[i] == word:
       new_text[i] == star
  return " ".join(new_text)

#2

here:

new_text[i] == star

two equal signs means check if equal, is that really what you want to do here?


#3

No, it’s not! Thanks


#4

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