0

How to print the words before a newline break?

I have a large text sperated by a new lines. I want to parse the words before the newline and append it to a list as a1. Then the words after the newline break as a2 and so on. Example: MM = "hello there how are you?\nIam good thanks" a1 should equal to "hello there how are you?" And a2 should equal to "I am good thanks"

22nd Mar 2021, 10:00 PM
Karzan
4 Answers
+ 2
a = MM.split("\n") print(a[0]) print(a[1])
22nd Mar 2021, 10:03 PM
visph
visph - avatar
+ 1
I solved it. I only needed to do MM.splitlines()
22nd Mar 2021, 10:03 PM
Karzan
0
also :D
22nd Mar 2021, 10:03 PM
visph
visph - avatar
0
visph Thanks buddy. :)
22nd Mar 2021, 10:04 PM
Karzan