- splitlines() is a python function which are used to split the string at the point of line break and store in form of list.
Syntax-
str.splitlines(number)
- here str is given string which we want to split.
- and if we add the number then it include the line break also.
Example
string is s="Thisnisnprogramming" where n shows the line break.
then s.splitlines() will give ["This","is","programming"]
and s.splitlines(10) will give ["Thisn","isn","programming"]
program-
s="thisnisnprogramming"
print("Original String isn",s)
print(s.splitlines())
print(s.splitlines(10))
print(s.splitlines(15))
print(s.splitlines(2))
print(s.splitlines(100))
print(type(s.splitlines()))
Original String is
this
is
programming
['this', 'is', 'programming']
['thisn', 'isn', 'programming']
['thisn', 'isn', 'programming']
['thisn', 'isn', 'programming']
['thisn', 'isn', 'programming']
<'class 'list'>