What goes in the blank?
# all subsets: each item is either left out or taken
def subsets(xs):
if not xs:
return [[]]
rest = subsets(xs[1:])
return rest + [[xs[0]] + r for r in ____]
Answer: rest
The subsets without xs[0] are rest; adding xs[0] to each of them gives the other half.
Play Problem Solving ▸