Hello everyone, Im very new to python so I am having a hard time with it. I am trying to input a set 's' and have it spit out 'result' which would be a list of all computed subsets of 's'.
I wrote the following code but its not working. When I make a set (call it b) and run subsets(b), I get a bunch of errors. What am I missing here?
def subsets(s):
result = [set()]
for xi in s:
newsubsets=[]
for subset in result:
newsubsets.copy(subsets)
newsubsets.add(xi)
newsubsets.append(newsubsets)
result.extend(newsubsets)
return result