>>> a='To be    or      not to   be'
>>> ' '.join(a.split())
'To be or not to be'

 

Use ' '.join(a.split())