Python Power Set of a List [duplicate]
问题 This question already has answers here : How to get all subsets of a set? (powerset) (17 answers) Closed 2 years ago . I am trying to implement a function to generate the powerset of a list xs . The general idea is that we walk through the elements of xs and choose whether to include x or not. The problem I'm facing is that withX ends up being equal to [None] (a singleton list with None ) because (I think) s.add(x) returns None . This isn't a homework assignment, it's an exercise in Cracking