10/censor ,i need help


#1

https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/1/4?curriculum_id=4f89dab3d788890003000096

error:
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?
thankyou

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

#2

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:


#3

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