random picks from a list

Duncan Smith buzzard at urubu.freeserve.co.uk
Thu Jun 12 16:23:31 EDT 2003


"Rogue9" <rogue9 at ntlworld.com> wrote in message news:3ee8dbd6 at shknews01...
> Hi All,
> I´m working on a program for lottery analysing and need to generate
> random numbers from a filtered list of numbers i.e. I have reduced the
> likely ¨winning¨ numbers to a smaller pool and have them in a list. How
> do i use the random funtion in Python to pick random numbers from this
> list?Is this the use of the seq argument in the random function?
> The documentation does not cover the use of all the arguments available
> for this function and my attempts to use if have been a failure.
> Guidance would be very much welcome Pythonistas,
> Thanks
> Lol McBride

Maybe you want random combinations?  One way, assuming 6/49,

>>> import random
>>> numbers = range(1, 49+1)
>>> random.shuffle(numbers)
>>> comb = numbers[:6]
>>> comb.sort()
>>> comb
[9, 18, 19, 33, 34, 42]
>>>

Duncan







More information about the Python-list mailing list