python list index - an easy question

BartC bc at
Sun Dec 18 17:36:00 EST 2016

On 18/12/2016 22:21, BartC wrote:
> On 18/12/2016 21:04, Michael Torrie wrote:
>> On 12/18/2016 09:21 AM, BartC wrote:
>>> So if you wanted a simple list giving the titles of the chapters in a
>>> book or on a DVD, on the colour of the front doors for each house in a
>>> street, usually you wouldn't be able to use element 0.
>> It also depends on whether you want to number the spaces between the
>> objects or the objects themselves. To use your DVD example, the first
>> chapter will probably be starting at time zero, not time one.
>> In another example, babies start out at "zero" years old not "one."  But
>> at the same time we refer the first year of life.  Maybe it's not a
>> phrase much used these days but it used to be common to say something
>> like "in my 15th year," meaning when I was 14.  Maybe a more common use
>> would be "the first year of my employment at this company."
> There's the fence analogy (perhaps similar to what alister said):
> You have a fence made up of one-metre-wide panels that fit between two
> posts.
> For a 10-metre fence, you need 11 posts, and 10 panels.
> The posts can conveniently be numbered from 0 to 11,

... 0 to 10.

That's the thing with zero-based; it might reduce some off-by-one errors 
but could introduce others.

With the panels you have 10 panels numbered 1 to 10; what could be 
simpler or more intuitive?


More information about the Python-list mailing list