splitlines() method in Python String Module
splitlines methodbreaks the string in different parts at the specified word or character and returns a list of lines.
Syntax:
str.splitlines(keeplinebreaks)Parameters:
keeplinebreaks is optional. This represents whether the line breaks should be implemented or not by provided Boolean values True or False.
Example-1:
text = "The future is AI\nWelcome to Harvard"
x = text.splitlines()
print(x)
Output:

Example-2:
text = "The future is AI\nWelcome to Harvard"
x = text.splitlines(True)
print(x)
Output:
