I'm trying to sort [1] a list of people randomly into groups. My guess is that a list of lists will do the trick here. However, the randrange fails with an empty range. How can I check for this? I thought that my pupils list wouldn't reach zero with the while len(pupils)>0: would keep it above 0.
Any help or advice would be appreciated. TIA Adam [1] def groups(pupils, size): toplist = [] tmplist = [] print len(tmplist) while len(pupils)>0: print len(pupils) while len(tmplist)<=size: print "tmplist is ", len (tmplist) #How many pupils are we talking about here? listlength = pupilslength(pupils) rand1 = random.randrange(listlength) tmplist.append(pupils[rand1]) pupils.pop(rand1) toplist.append(tmplist) tmplist = [] for i in toplist: print i print i -- http://www.monkeez.org PGP key: 0x7111B833 _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor