Skip to content
Advertisement

Tag: removing-whitespace

Remove all whitespace in a string

I want to eliminate all the whitespace from a string, on both ends, and in between words. I have this Python code: But that only eliminates the whitespace on both sides of the string. How do I remove all whitespace? Answer If you want to remove leading and ending spaces, use str.strip(): If you want to remove all space characters,

Advertisement