word is at index 0 this will yield
False. Since your return statement is inside the
if block, there is no return, hence,
Now when the return statement is taken out of the block (moved 4 spaces left) an exception is raised.
Traceback (most recent call last):
File "<stdin>", line 10, in <module>
File "<stdin>", line 7, in censor
UnboundLocalError: local variable 'rplc' referenced before assignment
Suggest drop the conditional and just act on the text directly, then return it.
return text.replace(word, "*" * len(word))
I would also suggest trying some other approaches besides the built-in. Something this simple can hardly be called practice.