10 censor


#1

it shouldn't be hard to tell that i'm no good at this. I think i get the lesson now but why doesn't thins code work?

def censor(text, word):
for word in text:
if word == censor:
word.append("*" * len(word))
print censor("this hack is wack hack", "hack")


#2

after pasting you code select the code and click </> then only the people can see the correct format of your code
you are not allowed to directly equates function with variable word word == censor

I will give my code. if you got any doubt reply me

def censor(text, word):
    star = ""
    length = len(word)
    while length > 0:
        star = star + "*"
        length = length - 1
    return str.replace(text, word, star)
print censor("this hack is wack hack", "hack")

#3

Another way of getting that answer:

def censor(text,word):
    star=""
    for w in word:
        star+="*"
    return str.replace(text,word,star)