Oops, try again. Your function fails on censor("hey hey hey","hey"). It returns "hey hey hey" when it should return "*** *** ***".
My reasoning was like this: make a list a, with all the apostrophes word has, by iterating through it; then the final sentence, beginning as a split list derived from text, has an x correspondent to word replaced by the written equivalent of a, and is then converted into text again.
My guess is that the problem is related to the ability of the program to assign to variable x within the if statement. Am I right?
def censor(text, word): a =  for x in word: a.append("*") sent = text.split(" ") for x in sent: if x == word: x = "".join(a) return(" ".join(sent))