I am trying to assign the output of itertools combinations function to a numpy array and it is creating a blank array. Why does this code not work correctly?
import numpy as np
from itertools import combinations
A=[10,5,7,90,4,200,64]
B=combinations(A,5)
NA=np.zeros([5,21],dtype=np.uint8)
print (list(B))
NA=list(B)
print (NA)
Bis a generator once exhausted, you can't iterrate again.list(B)will consume whole generatorBis a generator, which can be used only once. The 2ndlist(B)operates on a used, empty generator. Also that firstNA=...assignment does nothing for you; the 2nd overwrites it.NA = np.array(list(combinations(A,5)))is all you need. (along with some more basic Python study :) ).