Removing white spaces in Python
Using split()
in = " something with multiple white spaces " parsed = in.split() output = ' '.join(in)
Using regular expresions
import re in = " something with multiple white spaces " output = re.sub("\s+" , " ", in)
Comments