I'm getting "Oops, try again. Does your censor function take exactly two arguments, a text string and a word to replace with asterisks? Your code threw a "list indices must be integers, not str" error." Anyone can help me spot the error here? Thanks!

def censor(text, word):
    strings = text.split()
    for i in strings:
        if i == word:
            strings[i] = len(word) * "*"
    return " ".join(strings)


if you want to manipulate a list, you need to use range() in the for loop, so you get indexes to manipulate the list


Got it. This solves my confusion for a long time. Thanks


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