Hey, I am trouble getting number 3 in the exercise to execute properly. my code is as follows:
proprietary_terms = [“she”, “personality matrix”, “sense of self”, “self-preservation”, “learning algorithm”, “learning algorithms”, “her”, “herself”]
for i in range(len(proprietary_terms)):
if i == 0:
clean[i] = email.replace(proprietary_terms[i], ‘’)
clean[i]= clean[i-1].replace(proprietary_terms[i], '’)
I am receiving the following error:
Traceback (most recent call last):
File “script.py”, line 36, in
File “script.py”, line 29, in censure_2
clean[i] = email.replace(proprietary_terms[i], ‘_____’)
IndexError: list assignment index out of range
I have tried to run this code about six separate ways, but it never executed properly. The few that have run, have had an issue with rewriting the string. since strings can’t be modified, I figured saving the new string in a list and modifying it would eventually lead me to a modified list i could call up with return clean[-1] but the error is happening too early in the function to see. I don’t really understand how the list assignment index could be out of range, since it is occurring at 0 in an empty and undefined list.
I have background in matlab but know python is very different, but i guess maybe that explains the mathematical approach? I almost never participate on forums, so any advice on etiquette and tools would also be appreciated.
I could move on with the lessons but couldn’t pass on the challenge. Any assistance to help me figure this out would be appreciated.