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)
    return " ".join(lst)
print censor("alf pee", "pee")

a == b

is a bool not a string.


thanks! that was the problem i was looking for!


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


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