"George Sakkis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "rbt" <[EMAIL PROTECTED]> wrote: > > > Say I have a list that has 3 letters in it: > > > > ['a', 'b', 'c'] > > > > I want to print all the possible 4 digit combinations of those 3 > > letters: > > > > 4^3 = 64 > > > It's actually 3^4 = 81 (3 candidates/choice ** 4 choices)
Yes. You get a cigar! Someone else (Jack Diederich) also mentioned "This is called a cartesian product, ..." Right again. Now I can't help injecting that SQL is custom made for returning a cartesian product. Given a table called [Letters] containing a field [Letter] with (3) records Letter = 'a', 'b', 'c' SELECT CONCAT(t1.Letter, t2.Letter, t3.Letter, t4.Letter) FROM Letters As t1, Letters As t2, Letters As t3, Letters As t4 Will return those 81 combinations in an eyblink. In order to stay on topic, you are required to call your favorite SQL engine from Python :-) Thomas Bartkus -- http://mail.python.org/mailman/listinfo/python-list