How to Count Words, Sentences, Questions, Commas from Paragraph in Python

How to Count Words, Sentences, Questions, Commas from Paragraph in Python


Hello, again buddy! I am back with a new post that will let you the python programming language and you will also know that how to Count Words, Sentences, Questions, Commas from Paragraph in Python easily just use the code of Python with including its main built-in functions as well as an expert developer.

I would like to share the basic code for beginners either the new person can start the python programming code from today.

Count Words, Sentences, Questions, Commas from Paragraph in Python

Count Words, Sentences, Questions, Commas from Paragraph in Python

So, basically, you need some code if you are looking to count that how many words you have written in your article and how many sentences, my friends have been asking me please tell me how do you find the questions in paragraph and commas so, I thought how do I tell them so, this is a simple way you and my friends can learn new things from today.

Read more: Find Phone Number From Paragraph in Python

Don’t miss this one: WhatsApp Sniffer APK 2019 (Updated) Download For Android

So, first of all, you need to write a paragraph in a variable than make it first now.

paragraph = "I love my Country. Do you like cheese? What do you do? I would like to start a new job, do you know?"

In the above paragraph, I wrote some words, few sentences, and added two questions marks and having one comma over there so now I’m going to start the coding at here.

Make the variable of words, sentences, question, commas as well as no more.

words = 
sentences = 
questions = 
commas =

Okay, I hope you have understood to the above code and then follow now.

words =  paragraph.split(" ")
sentence = paragraph.split(".")
question = paragraph.split("?")
comma = paragraph.split(",")

I am using split built-in functions for breaking the space, dot, question mark, and comma then easy to print it out.

print(" Characters", len (strg),"\n And ", len(words)," words","\n And ", len(sentence), "sentences", "\n The Question are", len(question), "\n And the commas are", len (comma) )

Okay, guys! now after printing the value you will get the answer and had counted. WIth Count Words, Sentences, Questions, Commas from Paragraph in Python.

Here’s the screenshot of my coding.

Python programming code
My code.
paragraph = "I love my Country. Do you like cheese? What do you do? I would like to start a new job, do you know?"
 words= paragraph.split(" ")
 sentence= paragraph.split(".")
 question=paragraph.split("?")
 comma =paragraph.split(",")
 print("Characters",len(paragraph),"\nAnd ", len(words)," words","\nAnd ", len(sentence)," 
 sentences","\nThe Question are",len(question),"\nAnd the commas are",len(comma))

That’s all my coding whatever I did today in my software. I hope you like it and understand.

Thanks for visiting, have a nice day.


Leave a Comment