Please can I get some help with the spacing either at the beginning or end of the "text" sentence which I am monitoring for a specific word to amend.
It is very frustrating as I have tried several combinations - I have placed the + " " part of the code in line 6 both at the end and the beginning and it still gives the problem that "Hey Hey Hey!" is being deleted correctly but with one space before or after the phrase depending on where I put the + " ". I tried using the " ".join("*" * len(word)) code and that also gives a similiar error for "Hey Hey Hey!".
Oops, try again. Your function fails on censor("hey hey hey","hey"). It returns "*** *** *** " when it should return "*** *** ***".
Replace this line with your code. def censor(text, word): split_up = text.split() other_word = "" for data in split_up: if data == word: other_word += "*" * len(word) + " " else: other_word += data return other_word