+ 1

How do i remove an empty line from a string of lines

I have a string which was extracted from a json, the string has multiple lines with data ending with \n some of the lines have no data only the \n. I can't find a way to remove the lines that have only \n in them, please help.

11th Oct 2017, 1:56 PM
Aaber
3 Respostas
+ 3
if you have "\n\n" You know your are having an empty line
11th Oct 2017, 2:08 PM
Martin Möhle
Martin Möhle - avatar
+ 3
This feels wasteful, but it works. This is not a best answer; maybe use it to compare examples: print("\n".join(originalText.split("\n\n")))
11th Oct 2017, 2:16 PM
Kirk Schafer
Kirk Schafer - avatar
0
I will test
11th Oct 2017, 2:16 PM
Aaber