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.
this program is supposed to do the following:
1) split the text string into a list
2) sets variable to legth of the "word" argument
3)creates a loop that says for each element of the list text_split compare that element to "word"and if it is equal then that element of text_split is now the word length multiplied by the "*".
4) at the end of the loop the list "text_split" (along with its new elements) is transformed back into a string and given the variable name "censored".
5) finally i return censored (the modified string)
is the problem here with my logic as described above or the code i have used to implement this logic?
def censor(text, word): text_split=text.split() word_length=len(word) for i in text_split: if text_split[i]==word: text_split[i]=word_length*"*" censored=" ".join(text_split) return censored