mercredi 8 juin 2022

How would you build in criteria when using Random assign people to groups

I would like to assign people randomly to a group. I have used the following code from an existing script but I would like to add a criteria where "Kimani" is always no. 2 in a group

'''
import random

participants= 
["Alex","Elsie","Elise","Kimani","Ryan","Chris","Paul","Chris1","Pau2l", 
"Chris3","Paul3"]
group=1
membersInGroup=5

for participant in participants[:]:               # only modification
if membersInGroup==5:
    print("Group {} consists of;".format(group))
    membersInGroup=0
    group+=1
person=random.choice(participants)
print(person)
membersInGroup+=1
participants.remove(str(person))
'''



Aucun commentaire:

Enregistrer un commentaire