I tried this exercise using two functions and both of them did not work and I would like to find out the reason why.
the first function below doesn't work at all.
second function only returns "hey *** ***", leaving the first hey uncensored.
I will be very grateful for any explanations on why the functions fail to work! thanks in advance.
###function 1 def censor(text, word): til = text.split() for w in til: if w == word: w = "*" * len(word) return " ".join(til) ###function 2 def censors(text, word): til = text.split() for w in til: if w == word: til.remove(w) til.append("*" * len(word)) print til ##just to see the list return " ".join(til)