Need help on CENSOR problem


#1


i dont know what mistake i made.. can anyone point it out??

and pls correct my logic and explain it


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


#2

@cssrunner42151,
Try to use following code
and update to the correct format

def censor(text,word):
    print text.split()
    #you will have to capture the split() in a variable
    for i in text.split():
        if i==word:
            print i
            #text[i]="*"*len(i)
    print ''.join(text)
    return ' '.join(text)
    
print censor("this text is a text","text")

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.