Given a list like N = [10,7,6,5,4,3,2,1]
and PooledMoney=23
I need to print all lists like given below
[10,7,6]
[10,7,5,1]
[10,7,3,2,1]
[10,6,5,2]
[7,6,5,3,2]
This is my attempt:
for L in range(0,len(N)+1):
for subset in itertools.combinations(N,L):
#print subset
for i in subset:
sum = sum + i
if(sum==PooledMoney):
print subset`
This doesn't print the correct subsets.