Slice confusion : a[n:p] is a list exclude the last element p (thus spoke Dijkstra)

Changjune Kim juneaftn at REMOVETHIShanmail.net
Mon Apr 28 15:47:30 EDT 2003


A bit related to this is,

"Why Numbering Should Start At Zero" by Edsger Dijkstra at
http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF

He explains why a) is preferred in the following list:

 a. 2<= i < 13
 b. 1< i <=12
 c. 2<= i <= 12
 d. 1< i < 13


And then continues on to explain why b) is preferred in the following list:

 a. 1<= s < N+1
 b. 0<= s < N

With warmest regards,

June





More information about the Python-list mailing list