Python - how to separate paragraphs from text?

kom20 picture kom20 · Nov 10, 2018 · Viewed 11.4k times · Source

I need to separate texts into paragraphs and be able to work with each of them. How can I do that? Between every 2 paragraphs can be at least 1 empty line. Like this:

Hello world,
  this is an example.

Let´s program something.


Creating  new  program.

Thanks in advance.

Answer

roeen30 picture roeen30 · Nov 10, 2018

This sould work:

text.split('\n\n')