I wrote this because we wanted to do Secret Santa this year but Joe’s daughter’s live in California and wouldn’t be getting here until Dec 22nd. Joe used Bandcamp email voodoo to use the file generated to send the emails anonymously.
# Pair names for secret santa presents import random as r import sys f = open('TestSanta.txt','w') names = ["Joe","Alexa","Hannah","Xander","Kate","Soley","Max"] secretsanta = ["Joe","Alexa","Hannah","Xander","Kate","Soley","Max"] for name in names: x=r.randint(0,len(secretsanta)-1) receiver=secretsanta[x] while name is receiver: if len(secretsanta) == 1: print "Run again" sys.exit(0) else: # If you get your own name put it back and pick again # Want to go back to beginning of loop x=r.randint(0,len(secretsanta)-1) receiver=secretsanta[x] f.write(name +','+ receiver + '\n') del secretsanta[x] f.close()
*like