1# Using str.splitlines() method, you can split a string by new lines
2
3# Example 1
4string = "Line 1\nLine 2\nLine 3\nLine4"
5string = string.splitlines()
6print(string)
7# OUTPUT
8['Line 1', 'Line 2', 'Line 3', 'Line4']
9
10# Example 2
11string = """Hello world.
12My name is bob
13
14I like dogs"""
15string = string.splitlines()
16print(string)
17# OUTPUT
18['Hello world.', 'My name is bob', '', 'I like dogs']
19
20# 2.X Documentation: https://docs.python.org/2/library/stdtypes.html#str.splitlines
21# 3.X Documentation: https://docs.python.org/3/library/stdtypes.html#str.splitlines