In every topic here I see long batches of code to solve the problem. I did it in 4 lines, it seems to work fine and Codecademy accepts it. I can't shake the feeling I messed something up though, since I got such a tiny function.
Here's what I did:
def censor(text, word): if word in text: text = text.replace(word, "*" * len(word)) return text