Censor: Not returning full Text


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/4?curriculum_id=4f89dab3d788890003000096



def censor(text,word):
    for i in text:
        for j in word:
            if i==j:
                word=word.replace(j,"*")
    return word

What is going wrong? Is my Loop being stopped after just 1 iteration?


#2

Your code is doing what you want it to do, that is: if text has a faul word, replace it with "*".

But the problem is, we want "*" * len(word), so that we get the input, our problem wants, "*** *** ***"
Instead of "***"


#3

That means it's basically replacing the words not the letters! right?


#4

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