Created
August 19, 2015 22:46
-
-
Save jmk/2f0e400c38f4466e6d6c to your computer and use it in GitHub Desktop.
Raffle script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A quickie raffle script that uses random.org to choose winning entries. | |
import urllib2 | |
winners = 1 | |
entries = [ | |
"foo", | |
"bar", | |
"baz", | |
"quux", | |
"asdf", | |
"zxcv", | |
"qwerty", | |
] | |
url = "https://www.random.org/sequences/?min=0&max=%d&col=1&format=plain&rnd=new" % (len(entries)-1) | |
data = urllib2.urlopen(url).readlines() | |
results = [int(x.strip()) for x in data] | |
print "Your winner(s) are: " | |
print ", ".join([entries[i] for i in results[:winners]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment