How to display a powerset using the following code? what is the mistake and where? why the output is not getting displayed? What to do to display the output?
def power_set(items):
N = len(items)
# enumerate the 2 ** N possible combinations
for i in range(2 ** N):
combo = []
for j in range(N):
# test bit jth of integer i
if (i >> j) % 2 == 1:
combo.append(items[j])
yield combo
0 Answer(s)