Obviously it would be helpful for someone to explain why this does not work. Also, if you would, please show a more concise way to do this because I've only been coding for a few years (high school), and doubt I'm doing this the best way. Thanks in advance.
Error: list indices must be integers, not str
def censor(text, word): string = "" words = text.split(" ") #.split() returns a list for i in words: if words[i] != word: string = string + words[i] + " " else: string = string + len(word)*"*" + " " return string