range(start,stop)

Mikael Olofsson mikael at isy.liu.se
Mon Feb 14 09:18:59 CET 2000


On 11-Feb-00 Moshe Zadka wrote:
 >  range(0, n) is a list with n elements, so
 >  
 >  for i in range(0, n): # equivalent to range(n)
 >      print "hello"
 >  
 >  will print "hello" exactly n times.

This behavour of range doesn't bother me (any more), but your example
isn't really that good. It would be just as readable and logical to 
let range stop at stop as the original poster wanted, i.e. range(1,n)
could be a list of n elements and 

for i in range(1, n):
    print "hello"

would do.

/Mikael

-----------------------------------------------------------------------
E-Mail:  Mikael Olofsson <mikael at isy.liu.se>
WWW:     http://www.dtr.isy.liu.se/dtr/staff/mikael
Phone:   +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
Date:    14-Feb-00
Time:    09:14:01

This message was sent by XF-Mail.
-----------------------------------------------------------------------




More information about the Python-list mailing list