Steven D'Aprano <[EMAIL PROTECTED]> writes: > Generally, lottery numbers are selected from a range, e.g. one to forty. > So rather than passing a global list, just pass the maximum number: > > def getNumbers(maxn=40): > L = range(1, maxn+1) > random.shuffle(L) > return L[0:5]
Why is everyone using shuffle? Python 2.3.4 (#1, Feb 2 2005, 12:11:53) [GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import random >>> random.sample(xrange(1,41), 5) [24, 15, 9, 39, 19] -- http://mail.python.org/mailman/listinfo/python-list