Before I return the result, I print it out and it's the same as the expected result. But, it said I was wrong since the result of my function is not the same as the expected result. And I am confused.
When the input is ('hey hey hey','hey')
the expected result is '*** *** ***'
which is exactly the same as the result which was printed out
def censor(text, word): textl = list(text) wordl = list(word) for i1 in range(len(textl)-len(wordl)): #print textl[i1:i1 + len(wordl)] status = cmp(textl[i1:i1 + len(wordl)], wordl) print status if status == 0: for i2 in range(len(wordl)): print textl[i1+i2] textl[i1+i2] = '*' print textl[i1+i2] print ''.join(textl) return ''.join(textl) censor('hey hey hey ', 'hey')