10/censor ,i need help



Oops, try again. Did you create a function called censor? Your code threw a "global name 'censor' is not defined" error.

please i need a help , why it does not work?

def censor(text, word):
     text = (str(text)).upper()
     word = (str(word)).upper()
     j = len(word)
     for item in text:
         if item == word:
             item = "*"*j
             return text


Your function is correctly defined, please try to:

  1. copy your code;
  2. click reset code;
  3. click save & submit code;
  4. paste your code back into the editor;
  5. click save & submit code.

You should get Your function fails on censor("hey hey hey","hey"). It returns "None" when it should return "*** *** ***" error, and that's ok because your function does not work well, but maybe you will be able to solve this problem without our help :slight_smile:


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