def censor(text,word): word2= s="" word2=text.split(" ") for i in word2: if i==word: for t in i: s+="*" else: s+=i s+=" " text=s return text
you have an additional space at the end of your sentence, this causes the error
you could string slicing to get rid of it
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.