I was doing the Censor exercise. I had forgotten quite a lot of important commands (like list-making, join text, etc), and thus being unaware of them, and being too proud (or foolish?) to click on the hint, I decided to work it out the long way.
There is no problem with the code, in terms of results. But is it really something that should be satisfying? Do you have any tips on how I should study built-in commands, functions, etc, and how to optimize the coding? I'm a total beginner, with a completely different background, so... layman terms please?
def censor(text,word): dummy_text = "" dummy_list =  new_word_start = 0 number_of_words = 0 for i in range(len(text)): dummy_dummy = "" dummy_end = text+"#" if new_word_start < len(text): for j in range(new_word_start,len(text)): if text[j] != " ": dummy_dummy += text[j] else: new_word_start = j+1 number_of_words += 1 print new_word_start break dummy_list.append(str(dummy_dummy)) for i in range(len(dummy_list)): if dummy_list[i] == word: dummy_list[i] = "*" * len(word) dummy_list = dummy_list[0:number_of_words+1] final = "" for i in range(len(dummy_list)): final = final+" "+dummy_list[i] return final[1:] print censor(raw_input("gimme text: "), raw_input("now gimme censor: "))