On Dec 23, 2:04 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > def combinations(seq, n): > if n == 0: > yield [] > else: > for i in xrange(len(seq)): > for cc in combinations(seq[i+1:], n-1): > yield [seq[i]]+cc > > >>> for c in combinations(range(4), 3): > > ... print c > Steven
Thank you Steven, it works. I am so new to Python that I don't understand fully how this function works to be able to adapt it to my original problem. I wish I had a teacher :-) Merry Xmas -- http://mail.python.org/mailman/listinfo/python-list