the function is supposed to censor the words in the proprietary terms list:
proprietary_terms = ["she", "personality matrix", "sense of self", "self-preservation", "learning algorithm", "her", "herself"]
def censored_list(text, List):
for i in text:
for word in List:
if i == word:
new_text = text.replace(i, "*" )
return new_text
print(censored_list(email_two, proprietary_terms))
but insted i get:
Traceback (most recent call last):
File "script.py", line 19, in <module>
print(censored_list(email_two, proprietary_terms))
File "script.py", line 18, in censored_list
return new_text
UnboundLocalError: local variable 'new_text' referenced before assignment
another question, does the logic seems right?
EDIT:
Can anybody show me a working example code snippet of the code above?