I have already found a great solution to this task in the forum. However I wonder why my code does not work.
Here’s the code:
def censor(text, word): for i in word: if i.isalpha() and i.islower(): for word in text: word = "*" * len(word) return text censor("I love you", "love")
That’s the error message:
Your function fails on censor(“hey hey hey”,“hey”). It returns “hey hey hey” when it should return " *".
Could you explain me step by step why this code fails?
Thanks in advance!