I have large string which I split by newlines. How can I remove all lines that are empty, (whitespace only)?
pseudo code:
for stuff in largestring:
I also tried regexp and list solutions, and list one is faster.
Here is my solution (by previous answers):
text = "\n".join([ll.rstrip() for ll in original_text.splitlines() if ll.strip()])