Remove Cuss Words using Python

Cuss Words are the words that make your language sound very impolite, rude, and culturally offensive. Sometimes we need to identify and remove cuss words from a piece of text. So if you want to learn to remove cuss words, this article is for you. In this article, I will take you through how to remove cuss words using Python.

Remove Cuss Words using Python

In a research, it was found that on an average, 80-90 words that a person speaks every day, 50-70% of all the words are cuss words. So it means people find it normal while exchanging conversations with cuss words. But sometimes, we need to remove such words from a piece of text to make it available to the audience of every age group.

So to remove cuss words, by using the Python programming language, we need to install the better_profanity library in our Python environment. It helps identify and remove the cuss words by inserting the * symbol in each letter of a cuss word.

To install this Python library in your Python environment, you need to execute the command mentioned below in your command prompt or terminal:

  • pip install better_profanity

After installing this Python library, below is how you can write a program to remove cuss words using Python:

from better_profanity import profanity
text = "Please leave me alone and just piss off"
censored = profanity.censor(text)
print(censored)
Please leave me alone and just ****

So, as you can see in the output, the cuss word has been removed from the text, and we see four stars instead of the cuss word.

Summary

Cuss Words are the words that make your language sound very impolite, rude, and culturally offensive. In a research, it was found that on an average, 80-90 words that a person speaks every day, 50-70% of all the words are cuss words. I hope you liked this article on removing cuss words using Python. Feel free to ask valuable questions in the comments section below.

Aman Kharwal
Aman Kharwal

I'm a writer and data scientist on a mission to educate others about the incredible power of data📈.

Articles: 1370

2 Comments

Leave a Reply