Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created August 7, 2020 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/8fc8ceef3bb0f149c8498dc295039351 to your computer and use it in GitHub Desktop.
Save codecademydev/8fc8ceef3bb0f149c8498dc295039351 to your computer and use it in GitHub Desktop.
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, word):
list_to_string = ""
hashes = "#" * len(word)
email_censor = email.replace(word, hashes)
return email_censor
email_split = email_two.split()
list_to_string1 = ""
def email_advance(mail, words):
global list_to_string1
edit_email = ['']
edit_email[0] = email_split
for i in edit_email[0]:
for b in words:
list_to_string = " ".join([str(i) for i in edit_email[0]])
if i in b:
hashes = "#" * len(i)
list_to_string1 = list_to_string.replace(i, hashes)
edit_email[0] = list_to_string1.split()
else:
break
return edit_email[0]
print(email_advance(email_two, proprietary_terms))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment