dimanche 31 janvier 2016

Code to randomly select raffle from generated ones

I'm trying to find a code to select a random winner from all generated raffles and is there a faster way Python can generate more raffles quicker and generate millions if so how. Here's my code so far.

import random 

def genNumber(n = 4):
    return "".join([str(random.randint(0,9)) for i in range(n)])

for i in range(12365):
    word = random.choice(['blue', 'aqua', 'jade','plum', 'gold', 'navy', 'pink', 'grey', 'ruby', 'rose', 'teal',"lime",]) 
    print("{} {} {}".format(word.title(), genNumber(4), genNumber(4)))
random.choice(word)




Aucun commentaire:

Enregistrer un commentaire