So the challenge was to replace a specific word in a sentence with asterisks with equivalent length to that word - 3 letters --> 3 asterisks etc.
Section One does not work, but Section Two does - can anyone critique Section One and maybe point out the possible mistake I was making, as the logic seemed sound originally?
def censor(text, word):for c in text:if c == word: ## this line was totally wrongtext.replace(c, "*" * len(c))return text
The next segment does work, then CodeAcademy's answer was way different:
def censor(text, word):a = "*" * len(word)for c in text:nw = text.split(word)return a.join(nw)
How would you approach this task?