So what am i doing wrong,why adn how to fix.Also what to add and why.And is there a faster way to do this?
Error : Oops, try again. Your function fails on censor("hey hey hey","hey"). It returns "*** *** *** " when it should return "*** *** ***".

def censor(text, word):
    shit = ""
    sentence = ""
    text = text.split(" ") 
    for i in range(0, len(text)):
        if text[i] == word:
            shit = '*' * len(text[i])
            sentence += shit + " "
        else :
            sentence += text[i] + " "
    return sentence             
censor("this hack is wack hack", "hack")


there is a additional space at the end of your sentence, you could just slice it off (sentence[:-1]) just before your return statement, which is the easiest solution, otherwise you would have to create a different solution


I don't understand.If u mean the space between else and return functions i deleteed it and it didnt work


no, the space at the end of your censored sentence. you return:


i replaced the spaces with underscores, there is a space after your censored string, i suggest you use slice to slice it off


No idea what you are talking about and no idea what to do


what your censored sentence is:


what it should be:


i replaced the spaces with underscores, so you can see the spaces.

You either need to slice off the space at the end of the sentence, with slice like i showed, or you would have to rewrite your entire solution


What do i have to do.I don't get it.What should should i do to my code exactly?How it should look like?


i explained this thrice, you have to slice off the unnecessary space at the end of your censored sentence.

You should, just before you return your sentence, update the variable where the last character is sliced off:

sentence = sentence[:-1]

I can't do everything for you, there is a difference between helping and coding for you


True.Ok thank you for helping.


If you don't remember how slice works, you can always revisit the exercise where slice is explained, or check external documentation, where do you think you need to place slice? I would put nearly at the end of my function, just before the return sentence, since then your string is censored, and you want to cut off the unnecessary space before you return the censored string


If I am having a lot of trouble with these practice makes perfect problems, where should I go back to. I find myself having to look for help on almost everyone except the first on since starting the practice makes perfect segment. Thank you in advance.


They are tough challenges. That depends on what the problem is. Take a moment to realize what the problem is, think if you need a string, or list. Do i need list manipulation? String manipulation? Find those exercise. Look back over the exercise for some build in functions (split, join)

write some psuedo code (what are the steps?), write in plain english but in programming steps.

These challenges are designed to be taken slow, but to hugely improve your programming thinking skills


Thank you =) This helps a lot.