The splitlines() method returns a list with all the lines in string, optionally including the line breaks (if num is supplied and is true).
Following is the syntax for splitlines() method −
str.splitlines( num = string.count('\n'))
num − This is any number, if present then it would be assumed that line breaks need to be included in the lines.
This method returns true if found matching string otherwise false.
The following example shows the usage of splitlines() method.
#!/usr/bin/python3 str = "this is \nstring example....\nwow!!!" print (str.splitlines( ))
When we run above program, it produces the following result −
['this is ', 'string example....', 'wow!!!']