> At first I thought you might want itertools.combinations() > >>>> import string, itertools >>>> for t in itertools.combinations(string.ascii_lowercase, 3): > ... print t # list(t) if you actually need a list > ... > ('a', 'b', 'c') > ('a', 'b', 'd') > ('a', 'b', 'e') > ('a', 'b', 'f') > ('a', 'b', 'g') > [snip] > > but that gives > >>>> sum(1 for t in itertools.combinations(string.ascii_lowercase, 3)) > 2600
At the very least, that matches the expected result mathematically, since the number of combinations of 3 elements out of 26 possibilities is "26 choose 3". http://mathworld.wolfram.com/Combination.html and "26 choose 3" computes to 2600. ####################### >>> 26 * 25 * 24 / (3 * 2 * 1) 2600 ####################### _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor