[Tutor] help with random.randint

Wayne Werner waynejwerner at gmail.com
Wed Feb 3 12:47:35 CET 2010


On Wed, Feb 3, 2010 at 5:26 AM, David <ldl08 at gmx.net> wrote:

> Hello Eike,
>
> thanks for the explanation, all this is really helpful -- I certainly have
> learned sth. today!
> I wonder, though, how I would get my number pairs, which I need later on,
> if I were to follow your solution. I am asking because as I understand your
> code, the list terms is a list of integers here, but not of x,y pairs,
> right? (I can see that this was a problem of my code right from the start,
> btw.)
>
> David


I'll refer you to what I posted in (what appeared to me as) your other
thread:

If you want the unique pairs (i.e. (12,7) is equivalent to (7,12)), I
*think* you can do a simple chain:

pool = []
for x in xrange(1,13):
    for y in xrange(x, 13):
        pool.append((x,y))

because that will give you the sets ordered by the smallest - you'll get
1x1-12, then 2x2-12, etc.

HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100203/5266a378/attachment.htm>


More information about the Tutor mailing list