I would start by defining what “paragraph” means to your application. How much control do you have over the data format? Is a paragraph some text followed by a line with only a newline? Can you just count the number of blank lines and add one? What if the file only had “aaaa” in it – would that be one paragraph, or zero? What if there are multiple blank lines in a row?
“Do you not want to know who has taken it?” cried his wife impatiently.
“You want to tell me, and I have no objection to hearing it.”
This was invitation enough.
“Why, my dear, you must know, Mrs. Long says that Netherfield is taken
by a young man of large fortune from the north of England; that he came
down on Monday in a chaise and four to see the place, and was so much
delighted with it, that he agreed with Mr. Morris immediately; that he
is to take possession before Michaelmas, and some of his servants are to
be in the house by the end of next week.”
“What is his name?”
Like this 6 paragraph over there. I don’t count to blank line because sometimes 2 blank lines between paragraphs .
If you are sure that at least one blank line is always a new paragraph, you could just check for anytime there is either 1 or more blank lines. Did you need help working that out?
Although I just realized my example also gives you the positions of the paragraphs when you only actually asked to find out how many paragraphs there actually were, so if you still want the positions, just use len(paras) to get the number, otherwise just replace paras = append(paras, lineNo) with numParas++ or something.