python list index - an easy question
paul.christoph.goetze at gmail.com
Sun Dec 18 05:59:54 EST 2016
there is a nice short article by E. W. Dijkstra about why it makes sense
to start numbering at zero (and exclude the upper given bound) while
slicing a list. Might give a bit of additional understanding.
Am 17.12.2016 um 20:10 schrieb John:
> I am new to Python, and I believe it's an easy question. I know R and Matlab.
> [2, 3, 4, 5]
> My question is: what does x[1:5] mean? By Python's convention, the first element of a list is indexed as "0". Doesn't x[1:5] mean a sub-list of x, indexed 1,2,3,4,5? If I am right, it should print [2,3,4,5,6]. Why does it print only [2,3,4,5]?
More information about the Python-list