これは私が直面している問題です。new_word を返して出力するのではなく、「None」と出力するだけです。
text = "hey hey hey,hey"
word = 'hey'
def censor(text,word):
new_word = ""
count = 0
if word in text:
latter_count = ((text.index(word))+len(word))
while count < text.index(word):
new_word+= text[count]
count += 1
for i in range(len(word)):
new_word += '*'
while latter_count < len(text) :
new_word += text[latter_count]
latter_count += 1
if word in new_word :
censor(new_word,word)
else :
return new_word
print censor(text,word)