python list index - an easy question
alister.ware at ntlworld.com
Sun Dec 18 03:12:37 EST 2016
On Sat, 17 Dec 2016 11:10:22 -0800, John wrote:
> I am new to Python, and I believe it's an easy question. I know R and
> [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]?
as well as al the other excellent & detailed explanations
think of the slice working on the gaps between the elements (the ',') &
not the element itself
In the long run we are all dead.
-- John Maynard Keynes
More information about the Python-list