#If you want to remove LEADING and ENDING spaces, use str.strip(): sentence = ' hello apple' sentence.strip() >>> 'hello apple'