[Tutor] Random Number Randrange

Alan Gauld alan.gauld at btinternet.com
Mon Feb 12 15:04:05 CET 2007

<kubota2550 at gmail.com> wrote

> When I  use the function random.randrange(x,y) I never get the upper 
> limit y
> in the list.  I've tried the range 1,3 and never get 3.  If I choose 
> 1,4 I
> get 3 but never 4.  Is the upperlimit actually <y instead of <=y?

The documentation says it returns a value in the *range* min,max.

A range in Python returns the values min....max-1:

>>> print range(1,3)


Alan G. 

More information about the Tutor mailing list