Ask Your Question

Revision history [back]

This is from the Sage reference manual:

sage: X = Set([1,2,3])
sage: list(X.subsets(2))
[{1, 2}, {1, 3}, {2, 3}]

Or using pure Python tools:

sage: X = set([1,2,3])
sage: import itertools
sage: itertools.combinations(k, 2)
<itertools.combinations object at 0x4572cf470>
sage: list(itertools.combinations(k, 2))
[(1, 2), (1, 3), (2, 3)]