String Problem, What is it I don't understand?

news burkhard.nospam.kloss at kbcfp.com
Thu Jan 16 20:35:12 CET 2003


I think your misunderstanding is simply that indexing isn't done as
[start:length], but [start:end].  So you want
>>> day = xxx [3:5]
>>> year = xxx [6:8]
>>> day
'17'
>>> year
'03'
>>>


"Bubba" <bub at joos.us> wrote in message
news:300e2v422gc01dsc8pn66jvi7cpooqkpek at 4ax.com...
> I would expect to get the month day and year from the following, but
> day and year are null
>
> xxx = "01/17/03"
> month = xxx[0:2]
> print "month=",month
> day = xxx[3:2]
> print "day=",day
> year = xxx[6:2]
> print "year=",year
>
> Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on
> win32
> Type "copyright", "credits" or "license" for more information.
> IDLE 0.8 -- press F1 for help
> >>>
> month= 01
> day=
> year=






More information about the Python-list mailing list