Skip to content

Instantly share code, notes, and snippets.

@codeinthehole
Created April 5, 2012 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeinthehole/2310347 to your computer and use it in GitHub Desktop.
Save codeinthehole/2310347 to your computer and use it in GitHub Desktop.
Pick winners
import random
import time
def pick_winners(candidates, num_winners):
for i in range(num_winners):
time.sleep(1)
winner = random.choice(candidates)
print "Winner %d: %s" % (i+1, winner)
candidates.remove(winner)
print "\nSorry %s\n" % ", ".join(candidates)
py_candidates = ['Andre',
'Eleni',
'Phil',
'Andrew Ingram',
'Alex',
'Becky',
'Gump',
'Anthony',
'Kura',
'Matus']
print 'Picking python winners'
pick_winners(py_candidates, 6)
php_candidates = ['Marek',
'Duncan',
'Natalia',
'Miloud']
print 'Picking PHP winners'
pick_winners(php_candidates, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment