Censor-Solved!


#1



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


error message: Oops, try again. Did you create a function called censor? Your code threw a "global name 'censor' is not defined" error.
Says theres a syntax error on line 4, something wrong with the colon.

Any hints would be appreciated!


def censor(text,word):
    newtext=text.split()
    stars=("*"*len(word)
    for w in newtext:
        if w==word:
            newtext[newtext.index(w)]=stars
    text=" ".join(newtext)
    return text


#2

Oh god, i just hadn't closed my brackets :frowning:


#3

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