I would appreciate your help with censor dispenser task, part 3, where you have to censor all words from a list and replace them with allowed terms.
This is the task:
Write a function that can censor not just a specific word or phrase from a body of text, but a whole list of words and phrases, and then return the text.
Mr. Cloudy has asked that you censor all words and phrases from the following list in
Here is my code:
proprietary_terms = ["she", "personality matrix", "sense of self", "self-preservation", "learning algorithm", "her", "herself"] ok_terms = ["it", "individual pattern", "understanding", "safety", "special feature", "its", "itself"] def censor_two(email): for term in proprietary_terms: if term in email: email_censored = email.replace(proprietary_terms[proprietary_terms.index(term)], ok_terms[ok_terms.index(term)]) return email_censored print(censor_two(email_two))
Here is the error message I get:
Traceback (most recent call last): File "script.py", line 22, in <module> print(censor_two(email_two)) File "script.py", line 17, in censor_two email_censored = email.replace(proprietary_terms[proprietary_terms.index(term)], ok_terms[ok_terms.index(term)]) ValueError: 'she' is not in list
Here is a link to the task: https://www.codecademy.com/practice/projects/censor-dispenser
Thank you very much in advance!