Censor problem


#1




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]))
else:
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.


#2

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


#3

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