Please find the problem in my code


#1

CODE:

def censor(text, word):
word_list = text.split()
star = “*” * len(word)
result = ""
for item in word_list:
if item == word:
item = star
result = " ".join(word_list)
return result

print censor(“this hack is wack hack”, “hack”)

This code just prints the same text as output.


#2

This will have no effect on the original text. You are simply replacing the iterator, which is immediately following that replaced again by the next term in the iteration.


#3

A post was split to a new topic: Function


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.