Last active
December 23, 2015 22:09
-
-
Save ProProgrammer/6700823 to your computer and use it in GitHub Desktop.
This function called censor that takes two strings, text and word, as input and returns the text with the word you chose replaced with asterisks.
This file contains 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 match_characters(word1, word): | |
for i in word1.lower(): | |
for j in word.lower(): | |
if i == j: | |
return True | |
else: | |
return False | |
def censor(text, word): | |
textlist = text.split() | |
for char in textlist: | |
if match_characters(char, word): | |
text = text.replace(char, '*' * len(char)) | |
return text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment