Censor help plz



Could someone tell me what is wrong with my indentation?
Thank you!

Replace this line with your code.


In python, indentation is very important. Your return statement is meant to be inside of your censor function. Correct indentation:

def censor(text,word):
    for i in text.split()
        if i == word:
            return " ".join(censored)

PS: If there is still an error after indenting, make sure to look into if "censored" was already defined or not


here is another way you can nailed this ...

def censor(text, word):
while word in text:
text=text.replace(word, len(word)'')

print 'Here is your new text', text
return (text)


censor(text, word)


def censor(text, word):
text = text.split()
m = -1
for rijec in text:
m += 1
if rijec == word:
text[m] = "*" * len(word)
text = " ".join(text)
return text

print(censor("this hack is was hack", "hack"))

This maybe helpful~


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.