append = insert at the end of the list.
we can walk over what happens, the loop makes 3 iterations, so we start with:
["hey", "hey", "hey"]
okay, so then you remove the first one (index 0) and append it to the end:
["hey", "hey", "***"]
okay, so now the for loop moves on to index 1, removes the item and appends it to the list:
["hey", "***", "***"]
okay, so now the loop arrives at index 3, which contains
***, so the if condition evaluates to false.
The exercise is also going to test other strings like:
censor("this hack is wack hack", "hack")
this would mean you change the order of the words, you can't do this.
without using to much built in function, you have two options to make this program work:
range(), this will give you indexes which means you can replace items in your list, or built an if/else, the if should append censored words to an empty list and else should append words that don't require censoring.