10 - practice makes perfect


#1

I want to do a simplified version of the code, but I don't understand why it doesn't work quite right.

def censor(text, word):
    for word in text:
        str.replace(word, '*' * len(word))
    print text

#2

Forgot to mention, error is:
replace() takes at least 2 arguments (1 given)
but it seems I am using it correctly.


#3
def censor(text, word):
    for word in text:
        str.replace(word, '*' * len(word))
    print text

We should not need a loop for this one...

def censor(text, word):
    text = text.replace(word, '*' * len(word))
    return text