List slices

Daniel Klein DanielK at aracnet.com
Tue Oct 31 10:09:03 EST 2000


Given the list

    x = ['first','second','third','forth']

and

    x[-1]

returns ['forth'], it seems inconsistent that

    x[1:-1]

returns ['second',third'] instead of the expected ['second',third','forth'].
Can someone provide an explanation for this please?

thx,
Dan

[ ps Yes, I'm reading 'The Quick Python Book' :^) ]





More information about the Python-list mailing list