I have a python script parser, and an output, I receive a lot of strokes with spaces between lines, how I can delete them? I have strokes:
dog
dgfdfg
dgdfgdf
dfgdfgdfg
I want to obtain:
dfgdf
dgfdfg
dgdfgdf
dfgdfgdfg
You can simply replace multiple newline characters with a single one like below:
import re
lines = re.sub("\n+", "\n", lines)