So I almost have this working right, but I can't get the final output to translate from a list to a string. I thought that that is what
return "".join(final) does? It has worked for me before. What's wrong with ma code?
Btw, all the print statements are just so I can see what the code is doing at each step. It looks perfect until the very end.
def censor(text, word): split_text = text.split() final =  x = 0 print x print final while x <= len(split_text): if word == split_text[x]: final.append("*" * len(word)) x += 1 print x print final else: final.append(split_text[x]) x += 1 print x print final else: return "".join(final) print censor("this hack is wack hack", "hack")
0  1 ['this'] 2 ['this', '****'] 3 ['this', '****', 'is'] 4 ['this', '****', 'is', 'wack'] 5 ['this', '****', 'is', 'wack', '****'] Traceback (most recent call last): File "python", line 24, in <module> File "python", line 11, in censor IndexError: list index out of range