How to split multiline string to multiple lines in Python
In this tutorial, we are going to learn about how to split the multiline string to multiple lines and return a list of it.
Using splitlines() method
In python, we can use the
splitlines() method to split the multiline string into a list of each individual strings.
Here is an example:
mString = """Line 1 Line 2 Line 3 Line 4""" print(mString.splitlines())
['Line 1', 'Line 2', 'Line 3', 'Line 4']