def powerset(S): if S == []: return [[]] else: return powerset(S[1:]) + \ [x + [S[0]] for x in powerset(S[1:])]