Need some help on Censor Dispenser

Like my dad told me… “The best thing about computers is they do exactly what you tell them to do, the worst thing about computers is they do exactly what you tell them to do”

I obviously told it to do something I didn’t want it to do, I just don’t know how to change it yet.

You do, actually.
Because you can carry out this task manually. You have a reference.

I’m not sure, I thought I did. I had thought that it would iterate through the list of words and remove them from the original email, but its obviously not doing that

Overall the point here is that if billy makes pizza and ends up with hamburger, then you’re going to want to watch billy cook.

Dough, tomato sauce, pineapple. Pizza. You know how it goes, you just observe and compare and fix where different.

You don’t need a professional chef to point out the problem. You just need to look.

by manually do you mean going into the .txt file and changing it? That would sorta defeat the purpose. I’m not exactly sure what you mean

Write this down on paper:

a b c d e f

Under it, copy it but with a censored.
Under THAT, make a copy with d censored as well. From where do you copy?

You can answer that well enough that the question seems silly. Don’t detach yourself from your ability to reason about things just because you’re writing code. Same rules same universe same physics same everything.

I copy from the one furthest down the list. but I’m not sure how to access the copy furthest down the list.

Yeah but you do. Where did you put it? Or, put it somewhere.

In a variable. but how do I do it without creating a new variable each time?

And I put it below the previous copy. but I’m not sure how to access it

Well you have a variable, you could put it there.
Actually you have two, not sure what you’d use the second for, maybe remove that?

The email_propterm variable? I am trying to put it there. Not sure what the second variable is?

Ok I think I solved it…

email = "a b c d e f"
terms = ['a', 'd', 'e']

def proprietary_term(email):
  for i in terms:
      email = email.replace(i, "*")
  return email


I changed email_propterm to email, it returned “* b c * * f”. The irony is I have done that a number of times in previous lessons and practice, to the point I should have known, yet I failed to think of it.

Thanks for the help ionatan!

Now the only downside is that it does this researc***s, because “her” is one of the terms. So it is censoring “her” out of other words, so I’ll have to see if there is a way to prevent it from doing that, though I’m not sure.

You’d ignore code for a while and pick a strategy. Then implement that.

it also weirdly does this ***self, even though “herself” is on the list. So I’ll see if I can figure that out tomorrow.

***self doesn’t match herself, no reason why it would get replaced

If you consider your text to be a stream of words, you’d point your eyeballs at some location and compare a disallowed phrase to the next few words from that location.

…disregard code. you already know as much as what I just described.

I put “herself” before “her” in the proprietary_terms list and it fixed that. So now I just have to stop it from changing reasearchers to researc***s

Not without picking a different strategy.

If you decide that you’re going to use str.replace then you’ll end up with a big broken mess because the plan wasn’t sound to begin with.
this is why you disregard code. get your head out of the sand, start with a sound plan. then implement that.

but if you make a plan that makes sense, then that’s going to be something that can be implemented, and because you’ve planned it out you have a reference for what your code should be doing

the problem to be solving is the strategy. not the code. wrong problem to be looking at.