In your current code, try changing the line out = out[:-1]
to del out[-1]
. Both of these lead to out
deleting the last element, but in your current code, out
reassigned instead of using the same list. This leads to the fact that the characters are never removed from the original list, which, obviously, will be quite useless for output.
After making this change, here is the conclusion:
>>> print doCombine(target, x, len(target), 0, 0) ['w'] ['w', 'x'] ['w', 'x', 'y'] ['w', 'x', 'y', 'z'] ['w', 'x', 'z'] ['w', 'y'] ['w', 'y', 'z'] ['w', 'z'] ['x'] ['x', 'y'] ['x', 'y', 'z'] ['x', 'z'] ['y'] ['y', 'z'] ['z'] None
source share