10 - Censor / 15. Practice Makes Perfect


#1

Hi friends!

Having some issues with my code, it fails on censor(“hey hey hey”, “hey”)

`indent preformatted text by 4 spaces’

   cens = text.split()
    print cens
    for text[i] in cens:
        if text[i] == word: 
            text[i] == '*'*len(word)
    text = "".join(cens) '' 
    return text```

The print cens was just me trying to debug. Not too clear on what I'm doing with text.split() and "".join() so I don't know if they're completely wrong. 

Really appreciate the help :slight_smile:

#2

your function should return the result:

text = "".join(cens)
return text

now if we add a function call:

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

we can actually see what is happening, and the first issue which arises is your for loop:

for text[i] in cens:

that doesn’t work, that must be i instead of text[i], but that would give you the words, not really practical if you want to manipulate a list, use range().

Please make your indent show and post an updated version of your code: