Powersets in Python using itertools
itertools functions return iterators, objects that produce results lazily, on demand. You could either loop over the object with a for loop, or turn the result into a list by calling list() on it: from itertools import chain, combinations def powerset(iterable): “powerset([1,2,3]) –> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)” s = list(iterable) return … Read more