why is my code not generating the required output i.e. instead of printing *** *** it is printing * *

def censor(text, word):
    splitted = text.split()
    value = len(word) 
    update = "*" * value
    for string in splitted:
        if string == word:
            string = update
    new_string = " ".join(string)
    return new_string
print censor("hey hey", "hey")


this code:

if string == word:
   string = update

if string equals word, set string to update. update is (in the case of hey) is ***.

This doesn't make much sense, each time word is encountered, string is set to ***.

You will need a list (or string, but list is better) to append the (un)censored words to