Python3 String Splitlines
# Python3.x Python3 splitlines() Method
[ Python3 Strings](#)
* * *
## Description
The Python splitlines() method splits a string at line breaks ('r', 'rn', n') and returns a list containing each line as an element. If the parameter keepends is False, the line breaks are not included in the result. If keepends is True, the line breaks are retained.
## Syntax
The syntax for the splitlines() method is:
str.splitlines()
## Parameters
* keepends -- Specifies whether to remove the line breaks ('r', 'rn', n') from the output. The default is False, which does not include line breaks. If set to True, the line breaks are retained.
## Return Value
Returns a list containing each line as an element.
## Example
The following examples demonstrate the usage of the splitlines() function:
>>> 'ab cnnde fgrklrn'.splitlines()['ab c', '', 'de fg', 'kl']>>> 'ab cnnde fgrklrn'.splitlines(True)['ab cn', 'n', 'de fgr', 'klrn']>>>
* * Python3 Strings](#)
YouTip