question on slices
John Warney
john at yahoo.com
Mon Mar 25 17:10:07 EST 2002
I am sorta new to programming, i have had an intro to programming
using C++ and thats it. Other than that i have kinda read a few
things but now i am into Python.....blah blah blah.....
The issue that i have a problem with is slices. for instance let me
show you a snippet:
>>> numlist=[0, 1, 2, 3]
>>> numlist[1]
1
>>> numlist[2]
2
>>> numlist[1:2]
[1]
This last one doesnt make since to me since i am asking for a range
from 1-2. Why in the world does it give me 1 when i am asking for 1-2
which would logically be:
>>> numlist[1:2]
[1, 2]
but it's not. it doesnt make since. Just seems strange when i just
was in a C++ class and it would do the logical thing.
Rob
More information about the Python-list
mailing list