1 2 3 4 5 6 7 8 9 10 11 12
def censor(text,word): list = text.split() counter = 0 for i in list: if i == word: list[counter] = "*" * len(word) counter = counter + 1 string = ' '.join(list) return string val = censor("hey hey hey","hey") print val
1
*** *** ***