Censor Dispenser Challenge Project (Python)

Hey! Can somebody help me with a .find() replacement? My problem is located in part 4 of the Challenge. How can I find e.g. the word “help” twice in the text? Right now, my solution can only censor a word once, but not at it’s second appearance…

Look for #####task5######
Problem with .find()

Thank you!!

Have a look at the documentation for .find()- https://docs.python.org/3/library/stdtypes.html#str.find

It takes arguments which allow it to start at any index within the string which could help you skip words (if for example, you used the first index so as to skip the first appearance).

1 Like

Hi there,

I ran the solution code in terminal in my code editor, Atom. When I do this, it doesn’t censor negative words that should be censored following more than two occurrences of any two negative words.

Has anyone else caught this? Or am I the only one? My code is very similar to solution code and will not work so I thought I was missing a small mistake, but when I ran the actual solution code it just did not work.

Can you please provide the working solution to compare our projects to? Thank you.

Hi guys! Here is my solution to the Censor Dispenser project. Although I found it challenging enough and for sure I experimented a lot, I think I managed to make it work as it should. Any feedback is welcome!

Hi,

This was a good challenge, spent some time on it.

Good stuff. Thought i’d share.

Hi, I’m posting my first attempt at the Censor Dispenser. It mostly works, though i didn’t add in something for punctuation, and for some reason in email 4 the strings end up way longer than the words.

Hi all,

I’m pretty new to coding, and this is my first project. I create a class called Email which has a method called ‘censor’. This method has 3 parameters which are: censor_words, neg_words and all. These parameters help to specify which internal method to run later.

Within this ‘censor’ method, there are 3 internal methods called ‘terms_censor’, ‘neg_censor’ and ‘all_censor’.
The first two work with both lower case and title case words in input emails. the all_censor will run the first two, then identify the index of the substituted words, and replace the before and after words.

I would love to get feedbacks about the readability and enhancement of my code.
Cheers.