This solution passed as correct, but I’m not sure that it’s quite right. At least, I’d like it to be better.
def censor(text, word): strList = text.split() redact =  for i in strList: if word in i: i = "*" * len(word) redact.append(i) redacted = " ".join(redact) print redacted return redacted censor("just testing to test it", "test")
The above block returns: “just **** to **** it.” Whereas, I want to return “just ***ing to *** it”
Changing line 5 to:
if i in word:
Returns: “just testing to **** it”
I think this is better than my first solution. But not sure that either of them are quite right?