[Censor] It worked but was unable to get passed


#1

https://www.codecademy.com/en/courses/learn-python/lessons/practice-makes-perfect/exercises/censor-

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

I ran it on IDLE and it worked but I just can’t get passed on the website. Any suggestion?



def censor(text, word):
  length = len(word)
  newtext = text.replace(word, "*" * length)
  print (newtext)


Thank you guys!


#2

Hint, hint…

Not a very original solution, so must be copied. How about trying a solution that actually uses an algorithm, not a built-in. The lesson is not called practice makes perfect for show, but to indicate we should prractice (find multiple solutions).


#3

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