Censor


#1



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


I am wondering why this code isnt working.

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


def censor(text, word):
    text=text.split( )
    if item in text==word:
        wordindex=text.index(word)
        text.insert(wordindex, "*" * len(word)
    "".join(text)
    print text


#2

i would look at the error message in the output window, more useful

here:

text.insert(wordindex, "*" * len(word)

the parentheses don't match

i am not sure what you are attempting here:

if item in text==word:

it seems you try to compress a loop and a if condition in one, which is not possible


#5

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