[Tutor] re module / separator

Serdar Tumgoren zstumgoren at gmail.com
Thu Jun 25 00:19:12 CEST 2009

Ok -- realized my "solution" incorrectly strips white space from
multiword strings:

> Out[92]: ['a2345b.', 'a45453b.a325643b.a435643b.']

So here are some more gymnastics to get the correct result:

In [105]: newlist
Out[105]: ['a2345b.', '|', 'a45453b.', 'a325643b.', 'a435643b.', '|']

In [109]: lastlist2 = " ".join(newlist).rstrip("|").split("|")

In [110]: lastlist3 = [item.strip() for item in lastlist2]

In [111]: lastlist3
Out[111]: ['a2345b.', 'a45453b. a325643b. a435643b.']

More information about the Tutor mailing list