Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created Jul 4, 2019
Embed
What would you like to do?
Codecademy export
# These are the emails you will be censoring. The open() function is opening the text file that the emails are contained in and the .read() method is allowing us to save their contexts to the following variables:
email_one = open("email_one.txt", "r").read()
email_two = open("email_two.txt", "r").read()
email_three = open("email_three.txt", "r").read()
email_four = open("email_four.txt", "r").read()
proprietary_terms = ["she", "personality matrix", "sense of self", "self-preservation", "learning algorithm", "her", "herself"]
def censor(email):
return email.replace("learning algorithms", "******** *******")
#print(censor(email_one))
def censor2(email):
e = email.split()
n = []
for terms in proprietary_terms:
for word in e:
if terms == word:
n.append("*"*len(word))
else:
n.append(word)
return " ".join(n)
print(censor2(email_two))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment