The splitline() method will split the string at line breaks and return it in the form of a list.
#linebreak - (Optional) It specifies if the line break should be included or not.
By default it is False
#\n ,\r, \u2028, \f are line break representation
str1 = "Sam\r is good\n in math,\n but he is \nbad in english"
#if there is no line break representation, it returns a list with a single item
str2 = "Sam is good in math, but he is bad in english"
['Sam', ' is good', ' in math,', ' but he is ', 'bad in english']
['Sam\r', ' is good\n', ' in math,\n', ' but he is \n', 'bad in english']
['Sam is good in math, but he is bad in english']
Best learning portal that provides you great learning experience of various technologies with modern compilation tools and technique
Don't hesitate to give us a call or send us a contact form message