I'm trying to debug a program and am running into issues. Can anybody direct me to the issue here?
The program is meant to take a list of items, and returns the list of powersets for those items.
An example:
>>> getAllSubsets([1,2])
[[1,2],[1],[2],[]]
The code:
def getAllSubsets(lst):
if not lst:
return []
withFirst = [ [lst[0]] + rest for rest in getAllSubsets(lst[1:]) ]
withoutFirst = getAllSubsets(lst[1:])
return withFirst + withoutFirst