remove whitespace and n from text python code example
Example 1: remove extra spaces and empty lines from string python
"\n".join([s for s in code.split("\n") if s])
Example 2: remove all whitespace from string python
import re
s = '\n \t this is a string with a lot of whitespace\t'
s = re.sub('\s+', '', s)