Censor Code


#1




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


Actually (It returns "*** *** *** " when it should return "*** *** ***") the function return what is expect it. Why is it not considered a right one?. Thanks in advance for your help.


def censor(text,word):
    aster=str('*'*len(word))
    text=str(text.lower())
    word=str(word.lower())
    text_into_list=text.split(' ',-1)
    text_aster=[]
    s=''
    for i in  text_into_list:
        if i==word:
            i=aster
        text_aster.append(i+' ')
    return(s.join(text_aster))


#2

i don't see why you do this:

text_aster.append(i+' ')

i would do the spacing with join, using your method would give an additional space after the last word.

also remove the lower case conversions, the exercise wants the string returned without changes in upper/lowercase


#3

Thank you very much for answer. The code works now fine.:relaxed:


#4