10. Censor


#1

OK so I got this exercise correct but don't get the logic behind what the difference between these two are. The first one is correct and the second is not. Same indents for both

def censor(text,word):
    if text in word:
        new_text=word.replace(text,"*" * len(text))
    return new_text

def censor(word,text):
    if text in word:
        new_text=word.replace(text,"*" * len(text))
    return new_text

#2

You define the function in example1:

def censor(text,word):

in example2, you swap the arguments:

def censor(word,text):

now word holds the whole sentence, and text the word you want to censor.