Start New Discussion within our Software Development Community
import random
import time


badmStudentsF = ["FNAME1","FNAME2","FNAME3","FNAME4","FNAME5"]

badmStudentsM = ["MNAME1","MNAME2","MNAME3","MNAME4","MNAME5","MNAME6","MNAME7","MNAME8", "MNAME9", "MNAME10","MNAME11"]


random.shuffle(badmStudentsM, random.random);
random.shuffle(badmStudentsF, random.random);

print "HackLab Groups : " + time.strftime("%Y-%m-%d %H:%M")
print "++++++++++++++++++++++++++"
for i in range(0,len(badmStudentsM),1):
    if i == 4 or i == 8 or i == 12 or i == 16 :
                print "------------------------------"

    for i in range(0,len(badmStudentsF),2):
       if i == 4 or i == 8 or i == 12 or i == 16 :
            print "------------------------------"#
    print badmStudentsF[i]
    print badmStudentsM[i]
print "++++++++++++++++++++++++++"

I am trying to make a script that when it runs it will make 4 groups of 4.

Each group must have atleast one female name 'FNAME' in each print out.
Thank you for the help in advance.

OK, you have 16 names. So for the grouping you listed, you want 4 groups. Since there are 5 females, that leaves 1 extra.

As the names have been randomnized the sauce is in your printout. Use the group number as the loop variable.
And then a counter for F and M indexes into those name arrays.

So something like
findex = 0
mindex = 0
for groups 1 to 4
if group==1
print badmStudentsF[findex]
findex++
print badmStudentsF[findex]
findex++
print badmStudentsM[mindex]
mindex++
print badmStudentsM[mindex]
mindex++
else
print badmStudentsF[findex]
findex++
print badmStudentsM[mindex]
mindex++
print badmStudentsN[mindex]
mindex++
print badmStudentsM[mindex]
end for.

This article has been dead for over six months. Start a new discussion instead.