My version of censor!


#1



def censor(text, word):
s = text.split()
lst = []
final = ""
for wrd in s:
if wrd == word:
lst.append("*" * len(word))
else:
lst.append(wrd)

for i in lst:
    final += i + " "
return final.rstrip()


Replace this line with your code.

Continuing the discussion from 10 - Censor:

Continuing the discussion from 10 - Censor:


#2

Your code is very hard to understand without correct indentation, and it seems like you have only a part of your code.

The variable word doesn't exist in your code, or what we can see of it. Please fix this.


#4

def censor(text, word):
    string = text.split()
     lst = []
     final = ""
     for wrd in string:
         if wrd == word:
            lst.append("*" * len(word))
         else:
            lst.append(wrd)
      for i in lst:
            final += i + " "

return final.rstrip()


#5

What is the variable word as opposed to wrd? There is no specified difference in your code.