Created
July 18, 2015 10:26
-
-
Save ejmurray/b36086182500837c200f to your computer and use it in GitHub Desktop.
The answer to the codeacademy censor question. Only tested in PyCharm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def censor(text, word): | |
word_length = len(word) | |
print(text) | |
print(word_length) | |
censored_word = word_length * '*' | |
print(censored_word) | |
separated_text = text.split() | |
print(separated_text) | |
update = [censored_word if x == word else x for x in separated_text] | |
print(update) | |
censored_text = " ".join(update) | |
print(censored_text) | |
return censored_text | |
censor('here is the text here', 'here') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment