Censor


#1



censor


if I am leaving space in b/w " " the problem arises with "Yo go fro yo go" and it shows space b/w each alphabet but when I am leaving no space b/w " " then the problem arises with "hey hey hey" as it shows no space b/w them.


Replace this line with your code. 
def censor(text, word):
    text = text.split()
    constant = "*" * len(word)
    n = []
    for i in text:
        if i == word:
            n.append(constant)
        else:
            n += i
    return "".join(n)


#2

the biggest problem is here:

n += i

why do you not use append() here?


#3

Thank you so much.
The append() method worked after putting a space b/w "".
but why didn't

worked????


#4

because += behaves weird when adding to list, that is why we have append()


#5

OK, thank you so much.


#6