random.randint() wierdness.

Steve Lamb grey at despair.rpglink.com
Wed Aug 2 20:00:50 EDT 2000


On Wed, 2 Aug 2000 16:33:00 -0700, Emile van Sebille <emile at fenx.com> wrote:
>It prints! on RH6.2, win95, win98 with 1.6a2 and 1.52
>from the shell, idle and pythonwin.

    No, what he was pointing out was that the person was asking why
random.randint(1, 32) was producing a 0 in the output when it wasn't the
random call producing the 0...

>> > >>> for i in range(20):
>> > ...     random.randint(1, 32)
>> > ...     print i

    ... it was the print i which was printing what the for loop stuffed into
it.  range(20) will produce, IIRC, a list with numbers 0 through 20.  That is
where the 0 came from.

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
         ICQ: 5107343          | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------



More information about the Python-list mailing list