Max Noel wrote:
On Jan 23, 2005, at 22:08, Liam Clarke wrote:
Don't you mean
x=random.randint(0, lenoflist) ?? I'm assuming you want an integer.
random.randrange() returns an item (which can be a float or
whatever, but by default is an int) in the specified range. In that
case, an int between 0 and lenoflist.
The advantage over random.randint is that you can specify a step. Thus,
random.randrange(0, 257, 2) will return an even number between 0 and 256
inclusive.
Also the output of randint() is inclusive of both endpoints - with the
above statement you will have
0 <= x <= lenoflist. So in that case you would want lenoflist =
len(listcontents) - 1
Kent
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor