Use the strip() method Example >>> name = ' Steve ' >>> name ' Steve ' >>> name = name.strip() >>> name 'Steve'