Have no idea on how to put them toghether again


#1

I use
def censor(text,word):
l = text.split()
print l
total = [""]
for w in l:
if w == word:
total += "*" * len(word)
result = " ".join(total)
return result

print censor("hey hey hey","hey")

though the output becomes "* * * * * * * * *"
and i have no idea on how to put them toghether again


Censor, can someone help to make up my code?
#2

This is a list initialized with one element. While the element is the empty string, it is still a defined element. An initialized list should be empty.

    total = []

Since total is a list, we cannot concatenate to it the way we would a string. For this we use list.append().

    total.append( ... )