namuduri sujith
namuduri sujith

Reputation: 11

How to split a paragraph in to lines using Python libraries

I have a paragraph with some spaces and special characters and "....." 's.

I would like to know if there is any function in python which helps in splitting the lines in the paragraph with specified delimiters like "...."

Thanks in advance

Upvotes: 0

Views: 341

Answers (1)

Gaurav Agarwal Garg
Gaurav Agarwal Garg

Reputation: 113

Multiple ways to do this:

  1. string.split will return a list of lines and then string.join to form the sentences. split
input = # Your paragraph
input.split('...')  # will return a list of lines
''.join(input) # will return a set of lines
  1. regex.split likewise will return a list of lines (recommended) regex split
re.split(r'\.\.\.', input)

Upvotes: 2

Related Questions