-
Notifications
You must be signed in to change notification settings - Fork 12
/
lotto.py
42 lines (39 loc) · 951 Bytes
/
lotto.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# lotto picker by manny juan ([email protected] or [email protected])
from random import randint
def pick_lotto():
maxm=53
maxj=6
m=maxm
# create all numbers from 0 to m
r=range(m+1)
# start with an empty result
v=[]
for j in range(maxj):
# get ith number from r...
i=randint(1,m)
n=r[i]
# remove it from r...
r[i:i+1]=[]
m=m-1
# and append to the result
v.append(n)
return v
def run():
done=0
while not done:
try: x = input('\npress Enter for Lotto picks (Q to quit). ')
except EOFError:
x = 'q'
if x and (x[0] == 'q' or x[0] == 'Q'):
done=1
print('done')
else:
print(pick_lotto())
# immediate-mode commands, for drag-and-drop or execfile() execution
if __name__ == '__main__':
run()
else:
print("Module lotto imported.")
print("To run, type: lotto.run()")
print("To reload after changes to the source, type: reload(lotto)")
# end of lotto.py