Censor


#1



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


I don't know what's wrong!
File "python", line 10, in
File "python", line 9, in censor
TypeError: sequence item 1: expected string, bool found


def censor(text, word):
    lst = text.split()
    length = len(word)
    for wd in lst:
        if wd == word:
            wrd = wd == "*" * length
            lst.insert(lst.index(word), wrd)
            lst.remove(word)
    return " ".join(lst)
print censor("alf pee", "pee")


#2
a == b

is a bool not a string.


#3

thanks! that was the problem i was looking for!


#5

5 posts were split to a new topic: Oops, try again. Your function fails


#6

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