Hi, can someone please explain why I need to use enumerate here?
I think the reason is that index values aren't automatically generated in lists, you need to manually generate them with enumerate. I wanted to confirm that my thought process is correct, and see if anyone could provide additional insight.
Please also let me know if there are any ways that I can improve the code.
def censor(text, word): a = " " b = text.split() c = "*" * len(word) for index, wrd in enumerate(b): if wrd == word: b[index] = c return a.join(b)