Python Practice › String Programs › Program 84
Split a multi-line string into lines
Write a Python program to split a multi-line string into a list of lines.
Input
a three-line string
Output
['This string Contains', 'Multiple', 'Lines']
Approach
splitlines().
Solution
text = """This string ContainsMultipleLines"""print(text.splitlines())Output
['This string Contains', 'Multiple', 'Lines']
Learn the concept
New to this topic? Read the lesson, then come back.