SyntaxFix
Write A Post
Hire A Developer
Questions
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()])