Re: Two random lists from one list

2011-03-18 Thread noydb
Thanks All for your responses, all a help! -- http://mail.python.org/mailman/listinfo/python-list

Re: Two random lists from one list

2011-03-11 Thread Tim Chase
On 03/11/2011 12:21 PM, noydb wrote: I am just looking to see if there is perhaps a more efficient way of doing this below (works -- creates two random teams from a list of players). Just want to see what the experts come up with for means of learning how to do things better. ### import random

Re: Two random lists from one list

2011-03-11 Thread Dan Stromberg
Catenate the lists into a new list. Then randomize the order of the new list by iterating over each element in turn, swapping it with a random element elsewhere in the same list (optionally including swapping it with itself - that's easier and still gives good randomization). This gives linear ti

Re: Two random lists from one list

2011-03-11 Thread Peter Otten
noydb wrote: > Hello All, > > I am just looking to see if there is perhaps a more efficient way of > doing this below (works -- creates two random teams from a list of > players). Just want to see what the experts come up with for means of > learning how to do things better. > > Thanks for any

Re: Two random lists from one list

2011-03-11 Thread Chris Hulan
On Mar 11, 1:21 pm, noydb wrote: > Hello All, > > I am just looking to see if there is perhaps a more efficient way of > doing this below (works -- creates two random teams from a list of > players).  Just want to see what the experts come up with for means of > learning how to do things better. >

Re: Two random lists from one list

2011-03-11 Thread Miki Tebeka
You can use sets: teamA = set(random.sample(players, 4)) teamB = set(players) - teamA HTH -- Miki Tebeka http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Two random lists from one list

2011-03-11 Thread noydb
Hello All, I am just looking to see if there is perhaps a more efficient way of doing this below (works -- creates two random teams from a list of players). Just want to see what the experts come up with for means of learning how to do things better. Thanks for any responses! ### import random