2009/9/1 Luke Paireepinart <[email protected]>:
>>>> txt = "Hi          how are you?"
>>>> " ".join(txt.strip().split())
> 'Hi how are you?'

txt.strip() only remove leading and trailing white space so does
nothing in your example. However it works because txt.split() removes
the excessive white space between the text.

>>> txt
'Hi          how are you?'
>>> ' '.join(txt.split())
'Hi how are you?'

Greets
Sander
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to