Censor problem


def censor(text, word):
text_list = text.split(" ")
text_out = []
for w in range(len(text_list)):
if text_list[w] == word:
text_out.insert(w, "*" * len(text_list[w]))
text_out.insert(w, w)
return " ".join(text_out)

I was hoping that this would "*" at the correct indexed word but can't see why my code isn't working. Can you help?

Replace this line with your code.


Apologies, I got it!! Problem in the else statement....


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