10 - Censor


#1

I realize this is no where near the simplest way to solve this after looking through some other solutions, but can anyone tell me why the second part of my function is only operating on the first word of the list_text list?

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

def censor(text, word):
    replacer = []
    ltext = text.split()
    print(ltext)
    censored = []

#this portion of the function creates the censored version of the word to be censored
    for i in list(word):
        replacer.append('*')
    replacer = ''.join(replacer)
    print(replacer)

#this portion of the function rewrites the original text with the word to be censored replaced with asterisks
    for i2 in ltext:
        if i2 != word:
            censored.append(i2)
        else:
            censored.append(replacer)
        return ''.join(censored)
 
print(censor("well that was one hell of a poop", "poop"))

#2

Code and link to lesson would be appreciated. Can't do much with screenshot alone.


#3

included link and code. my bad.


#6

Indentation of two levels, should only be one.