manipulate string

Inyeol Lee inyeol.lee at siimage.com
Tue Oct 28 13:31:52 EST 2003


On Tue, Oct 28, 2003 at 07:06:36PM +0100, Chris wrote:
> It is me again.
> Unfortunately it doesn't work. Python doesn't accept [::2]
> TypeError: sequence index must be integer
> I use Python Release 2.2.3.
> Any ideas?

Then,

>>> s = "0123456789"
>>> " - ".join([s[i] for i in range(0, 10, 2)])
'0 - 2 - 4 - 6 - 8'

-Inyeol





More information about the Python-list mailing list