How to remove all white space in Python

edit  Updated by Benjo

If you want to remove leading and ending spaces, use str.strip():

sentence = ' newbie  dev'
sentence.strip()
>>> 'newbie  dev'
Remove ALL spaces in a string, even between words:
Remove ONLY DUPLICATE spaces: