I am on the practice makes perfect part of the learn Python 2 task. I am honestly having big problems figuring these out, and have resorted to the internet for solutions almost every single time.
This time, I decided I will not do that, so I tried doing it all by myself.
I have currently been stuck for 20-30 minutes, and this is the best I could come up with.
For me, it makes sense, logically, and should make the Word censored.
this is my code so far:
def censor(text, word): text.split() if word in text: text.remove(word) text.insert(word, (""*" * len(word)")) " ".join(text) return text
I split the text into a list.
Then I remove words in the text that is the same as “word”
then I insert the censor * in the place where the word was. where there are as many * as the len of the word.
Then i join the text by a space.
lastly I return the text.