Your function fails on censor("hey hey hey","hey"). It returns "xxx xxx xxx" when it should return " *"


#1

Hello,

My censor function does correct censorship. But is not accepted. Instead, " *" is required? Wth? Is there a bug?

Here is my funciton: https://repl.it/languages/python3

Screenshot:

def censor (text, word):
  pole = text.split()
  for index, slovo in enumerate(pole):
    if slovo == word:
      cenzura = 'x'*len(word)
      pole[index] = cenzura
  veta = " ".join(pole)
  print (veta)
    
    
censor ("hey hey hey", "hey")

#2

Use the asterisk, as expected, not an x.


#3

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