I believe when i join() the text i might be missing one parameter or simply not doing it properly.
I have tried to isolate the issue 'Suspicious part' but i still can't figure it out. I think that i have been exposed to the code for too long and need a new pair of eyes with a different point of view.
I have also run a few test in the python shell by adding a "TEST PRINT" and this is the output:
censor("this hack is a wack hack","hack")
'this **** is a wack hack'
censor("hey hey hey","hey")
censor(" ha man","ha")
censor(" ha man, you are funny ha ha hahaha ha ha","ha")
'** man, you are funny ** ** hahaha ha ha'
As you may have noticed, i got the the word to be censored right
But when i join them into a text, things get mess up
Replace this line with your code. def censor(text,word): text_list = text.split() censored_text = "" for wrd in range(0,len(text_list)): if text_list[wrd] == word: text_list[wrd] =text_list[wrd].replace(text_list[wrd],"*") * len(text_list[wrd]) #print(text_list[wrd])#TEST PRINT of text_list[wrd] is CORRECT else: text_list[wrd] = text_list[wrd] print(text_list[wrd]) censored_text = " ".join(text_list) #if am right this will be the "Suspicious"part return censored_text