The variable returns “[ ]” instead of desired results.
S = set(['a', 'b','d','z','x','y'])
collect = set()
step = set([''])
while step:
step = set(a+b for a in step for b in S if len(a+b) == 6)
collect |= step
print sorted(collect)
Also how could I make this a loop that plays through the combinations instead of a set?
Without knowing what “desired results” means, here’s your second problem:
(First problem is indentation.)
So…wtf are you doing with this line?