Can somebody explain, why the program doesn’t accept my code?
It goes as follows:
def censor (text, word): if word in text: my_text_split = text.split(" ") for i in range(0, len(my_text_split)): if my_text_split[i] == word: my_text_split[i] = "*" * len(word) text = " ".join(my_text_split) print text censor("hey hey hey", "hey")
The error message at the bottom says that the code doesn’t return the correct result for the string “hey hey hey”. Since it returns “*** *** ***” which should be correct I can’t quite grasp what’s wrong with the code
Thx for your help