So I'm doing exercise 10 and the hint suggest that we use .splt() and " ".join, and so I want to solve this using those two operators, the way that it seems that you are supposed to do it, and this is my code so far, but when I test it out on a python editor is just returns text, without word being censored.
def censor(text, word): a = text.split() b = "*" * len(word) for i in a: if i == word: i = b c = " ".join(a) return c print(censor("blah is a blah", "blah"))
My main question is, how do I replace word for its "*" equivalent before joining it, that is, while it is still at list format.
and while I'm at it, how do I simply replace an item in a list with something else. I tried replace() but it seems like it only works for strings. Is there a list equivalent?
P.S.: I took a break from Python for quite a while and I decided to return and pick up where I left off, so forgive me in advance if this is a silly mistake or is there is a really simple solution that I'm missing...