Censor


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/4?curriculum_id=4f89dab3d788890003000096#


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")


#2

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