Hello everyone, in the exercise given by the above link where I am required to replace a particular word in a sentence by '*', I have absolutely no idea where I am going wrong.
I expect the output to be correct but it simply returns the sentence back. It would be great if someone could point out the mistake in my code. Thank you so much.
def censor(text,word): if word not in text: return text else: words=text.split() for i in words: if i==word: for j in range(len(i)): i=i.replace(i[j],'*') print i s=" " return s.join(words)