[HELP] Censor


I'm stuck on censor

It looks as though its adding an extra space at the end of the return

def censor(text,word):
wrd = text.split()
newWord = ""
for x in wrd:
if x == word:
x = "*" * len(x)
newWord += x
return newWord



Actually I took out the + " " part of the code so my code above will write everything with no space. Prior to that I had the following:

newWord += x + " "

that's what added the extra space to the end.


to get rid of the space at the end of your string you could simply use string slicing to get rid of it?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.