How to get all subsets of a set? (powerset)
The Python itertools page has exactly a powerset recipe for this: Output: If you don’t like that empty tuple at the beginning, you can just change the range statement to range(1, len(s)+1) to avoid a 0-length combination.