random.randint() wierdness.

Steve Juranich sjuranic at condor.ee.washington.edu
Wed Aug 2 18:18:47 EDT 2000


Could somebody please explain this?

>>> for i in range(20):
...     random.randint(1, 32)
...     print i
... 
14
0    <---------   I don't get it.  Why?
14
1
10
2
12
3
32
4
18
5
24
6
27
7
31
8
24
9
23
10
21
11
7
12
14
13
4
14
26
15
23
16
2
17
14
18
32
19


As I read the library reference, it says that random.randint() is supposed
to return an integer between 1 and 32 (as I have called it above).  However,
the output shows that this is clearly not the case.  Could somebody please
tell me what's going on?  Is this a bug?  Thanks.


--------------------------------------------------------------------------
Stephen W. Juranich								sjuranic at ee.washington.edu
Electrical Engineering  	 	   http://students.washington.edu/sjuranic
University of Washington				http://truk.ee.washington.edu/ssli





More information about the Python-list mailing list