I made the below code for Part 3 of Censor Dispenser. This code is only replacing the first word from the “proprietary_terms” list, which is “she”. But it does not replace “She”, with a capital. I can understand why it not replacing the “She”, But I don’t see why it not iterating thru the proprietary_terms list. Please help.
email_two = open("email_two.txt", "r").read()
proprietary_terms = ["she", "personality matrix", "sense of self", "self-preservation", "learning algorithm", "her", "herself"]
for term in proprietary_terms:
What is the function of the
return keyword, and how could its position inside of your
for loop be affecting your program?
I tried every indentation level for the return. The “for” level causes this code to replace the last word in “proprietary_terms”. The level its at now replaces the first word. So I am seeing the first iteration and last iteration. I am lost on how to show the combined effect of all iterations.
That, to me, suggests that you either don’t understand the exercise or haven’t worked out methodically what you need to do in order to complete the task.
What you may find helpful, rather than clutching at straws and moving the
return because you think it’s the problem, would be to write out - not in code, but in words/bullet points - the process one ought to take to meet the objective.
Once you have that “written algorithm”, you can change your bullet points to code.
Perhaps you ought to review not just the position of your
return, but also the variable your function is acting on…