range(start,stop)
Moshe Zadka
moshez at math.huji.ac.il
Mon Feb 14 03:21:49 EST 2000
- Previous message (by thread): BUILD YOUR OWN C`A`B`L`E B`O`X READ ME!!!!!...,.,,,,,,..//././.,,,,,, 6529
- Next message (by thread): range(start,stop)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
On Mon, 14 Feb 2000, Mikael Olofsson wrote:
> 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"
Oh, I thought it was clear range has to start at 0 for the following
pydiom to work
for i in range(len(l)):
l[i] = l[i] + 1
Of course, if you decide lists start at 1, then range should stop at n,
but FORTRAN is (almost) dead and buried ;-)
--
Moshe Zadka <mzadka at geocities.com>.
INTERNET: Learn what you know.
Share what you don't.
- Previous message (by thread): BUILD YOUR OWN C`A`B`L`E B`O`X READ ME!!!!!...,.,,,,,,..//././.,,,,,, 6529
- Next message (by thread): range(start,stop)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Python-list
mailing list