What's wrong here? (10/15)


#1

def censor(text, word):
wordy = text.split()
for i in wordy:
if i == word:
i == '*' * len(word)
return " ".join(wordy)

Error:
Oops, try again.
Your function fails on censor("hey hey hey","hey"). It returns "hey hey hey" when it should return "*** *** ***".

I don't get what I'm doing wrong. . .


#2

Try this

def censor(text, word):
    wordy = text.split()
    for i in wordy:
        if i == word:
            wordy[wordy.index(i)]= "*"*len(word) #replace this line
    return " ".join(wordy)
print censor("hey hey hey", "hey")

#3

how did you make this code like this.. unbelievable .. I think i can not think of this.. I am beginner.. how long