[Tutor] Easy Problem

Luke Paireepinart rabidpoobear at gmail.com
Wed Sep 2 01:44:36 CEST 2009


On Tue, Sep 1, 2009 at 7:46 AM, Sander Sweers <sander.sweers at gmail.com>wrote:

> 2009/9/1 Luke Paireepinart <rabidpoobear at gmail.com>:
> >>>> 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.

It removes newlines as well.
I couldn't remember if split() would leave the trailing newline on the last
item.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090901/0e9f9aed/attachment-0001.htm>


More information about the Tutor mailing list