def censor(text, word):
t = text.split()
text2 = ''
for w in t:
if w == word:
text2 += '*' * len(word) + ' '
text2 += w
return text2

print censor("this hack is wack hack", "hack")

This is my code but it does not seem to be working. Can you please assist.


What error message are you being given? I'll bet it has to do with a trailing space in your return value.


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