Python String splitlines() MethodLast Updated : 2 Jan 2026 Python splitlines() method splits the string based on the lines. It breaks the string at line boundaries and returns a list of splitted strings. Line breakers can be a new line (\n), carriage return (\r) etc. A table of line breakers are given below which split the string. This method splits on the given line boundaries.
Signature of the splitlines() MethodIt has the following syntax: Parameters
ReturnIt returns a comma separated list of lines. Different Examples for Python String splitlines() MethodLet's see some examples of splitlines() method to understand it's functionality. Example 1Let us take an example to demonstrate the String splitlines() method in Python. Output: Java is a programming language ['Java is a programming language'] ['Java ', ' is a programming ', ' language'] Example 2Passing True to the method which causes to include line breakers into the list of string. See the example below. Output: ['Java \n', ' is a programming \r', ' language'] Example 3Let us take an example to demonstrate the String splitlines() method in Python. Output: ['Java ', ' is a programming ', ' language for ', ' software development'] Java is a programming language for software development Next TopicPython Strings |
We request you to subscribe our newsletter for upcoming updates.