Whrandom

Rainy sill at optonline.net
Tue May 15 02:12:07 EDT 2001


On Mon, 14 May 2001 19:11:01 GMT, Stephen Hansen <news at myNOSPAM.org> wrote:
>     You'll need to call whrandom.randint five times. Some of the
> possibilities are:
> 
> nums = []
> for i in range(0, 5):
>     nums.append(whrandom.randint(1, 1000))
> 
> or
> 
> nums = [whrandom.randint(1, 1000) for i in range(1, 1000)]

That'll make 999 ints :P Also, whrandom is deprecated in 2.1?
Instead:
>>> import random
>>> nums = [random.randint(1, 1000) for i in range(0,5)]
>>> print nums

> 
> The latter bit is a list comprehension, so will only work in 2.0+. (I
> believe.. then again, I never paid any attention to what was available in
> 1.6 since 2.0beta came out the same day. *grin*)
> 
> --S
> "Oskar Stefan" <st.oskar at vol.at> wrote in message
> news:9dp9md$bc0$1 at newsreaderg1.core.theplanet.net...
>> Hello!
>>
>> Could anyone give me an Example how can
>> I create 5 Random numbers between 1 and 1000.
>> I know this goes with whrandom but I
>> become only one number when I write whrandom.randint(1,1000)
>> but I will have 5 numbers between 1 and 1000 but no number
>> several times.
>>
>> thanks for your help
>>
>> osi
> 
> 


-- 
Don't be so humble -- you are not that great
        - Golda Meir



More information about the Python-list mailing list