String slices work only for first string character ?

D'Arcy J.M. Cain darcy at druid.net
Tue Dec 16 08:44:52 EST 2008


On Tue, 16 Dec 2008 13:35:27 +0000
"Barak, Ron" <Ron.Barak at lsi.com> wrote:
> Can any one explain why the following string slice works only for the first character, but not for any other ?

I think that you need to reread the docs on slices.

> print "|"+data[0:1]+"|"
> print "|"+data[1:1]+"|"

If you want the second character use "data[1:2]".

-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



More information about the Python-list mailing list