<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
Your function fails on censor(“hey hey hey”,“hey”). It returns “hey hey hey” when it should return " *".
(“hey hey hey”,“hey”) is an automatic input taken by the program.

<What do you expect to happen instead?>
According to my expectations, output should be “*** *** ***” instead of " *".


Replace this line with your code.

def censor(text, word):
  astr = " "
  if word in text:
    astr = "*" * 4
    text.replace(word, astr)
  return text
<do not remove the three backticks above>

I don't understand the output this program is expecting for the input ("hey hey hey","hey").


.replace() is dull to use, it allows for a single line solution. Please try to write your own function, it will teach you must more.


astr = " "

why isn’t the string empty, why would you want to have a leading space?


astr = "*" * 4

how do you know if you need four asterisks? hey has a length of 3, not 4


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