Censor problem: "list assignment index out of range" error


def censor(text, word):
list_text = text.split()
new_text = []
for i in range(len(text)):
if list_text[i] == word:
new_text[i] = "*" * len(word)
new_text[i] = list_text[i]
return " ".join(new_text)

Can anybody tell me what's wrong with the code, system replied: Oops, try again. Your code looks a bit off--it threw a "list assignment index out of range" error. Check the Hint if you need help!


You're using indexes that are valid for text to access elements from new_text which has a different length


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