How to strip mulitple and variable spaces in python

LJS93K 1300 10500
J38ZZ9 700 4750

What do you do when you have multiple spaces but not constant spaces in between words. You could you split in python but what that does is either strips all spaces or gives you a single space for each space found. this wouldnt be want you wanted. So you could do the following;

Read all the lines above into a String and then remove all new line chars or tabs and so on:

newString = re.sub([s], ,myListString)

Then join them to get a uniformly spaced string:

newString = .join(newString.split())


Leave a Reply

Your email address will not be published. Required fields are marked *