Python Practice › String Programs › Program 84

Split a multi-line string into lines

EasyString Programs · 84 of 106

Write a Python program to split a multi-line string into a list of lines.

Advertisement
Input
a three-line string
Output
['This string Contains', 'Multiple', 'Lines']

Approach

  1. splitlines().

Solution

Python
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.

More string programs

← All 106 String Programs

Leave a Comment