Skip to content

Instantly share code, notes, and snippets.

@sc0tt
Created July 12, 2014 12:49
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 sc0tt/e0592e1e4aba43c98ede to your computer and use it in GitHub Desktop.
Save sc0tt/e0592e1e4aba43c98ede to your computer and use it in GitHub Desktop.
Player picker
import random
name_list = None
with open("names.txt") as name_file:
name_list = [n.strip() for n in name_file.readlines()]
if len(name_list) % 2:
exit("Number of Players is not Even")
with open("out_names.txt", "w") as out:
while name_list:
p1 = name_list.pop(random.randrange(len(name_list)))
p2 = name_list.pop(random.randrange(len(name_list)))
out.write("%s - %s\n" % (p1, p2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment