Showing posts with label lotto. Show all posts
Showing posts with label lotto. Show all posts
Monday, 16 December 2013

Simple python lotto number picker

We had unusually big lotto the other day, so I wanted to play. I decided to write my own lucky number picker. This one picks 5 numbers out of 40 number pool, excludes last drawn number and returns your 5 number row in order.


#!/usr/bin/python
import random   
from random import choice
for k in range(10): # number of row to print
    pick = list(range(1,41))  # size of pool 40 +1 
    numbers = [] 
    i=1 
    for j in range(5): 
        num = random.choice(pick) 
        pick.remove(num) # remove selected number from pool
        numbers.append(num) 
        i=i+1
    print sorted(numbers)   # return sorted row
All ideas about improving this code are welcome.

--cheers