lundi 25 avril 2016

How to get a random list everytime?

I am trying to make a random list (subcommittee) of 3 students from committee. Then, I want to print a new random subcommittee 1000 times. Right now, the code I have is printing the same subcommittee 1000 times. How can I fix this?

import random

undergrads = ["ug_1", "ug_2", "ug_3", "ug_4"]
grads = ["g_1", "g_2"]
committee = undergrads + grads

subcommittee = []
for i in range(3):
    add_sub = random.choice(committee)
    subcommittee.append(add_sub)

for j in range(1000):
    print subcommittee




Aucun commentaire:

Enregistrer un commentaire