This a problem I'm having quite often; the message is, "Did you create a function called [censor]? Your code threw a "global name 'token' is not defined" error."
Does text.split() automatically slice the string into individual words?
I'm used to the syntax "for i in word", but that's for characters; does something like the below work for words in a phrase?
def censor(text, word): # return text with the word you chose replaced by asterisks text = raw_input("Please enter a phrase") word = raw_input("Please enter a word to be replaced with asterisks") text.split() if token in text == word: replace = len(token) * "*" text.join(text, replace) return censor