This might be simple, but I got stuck for quite some time.
I was trying to iterate two combinations. But it didn't go through all the items.
itt_1 = [1, 2, 3]
comb_1 = combinations(itt, 2)
itt_2 = ['a', 'b', 'c']
comb_2 = combinations(itt_2, 2)
count = 0
for ii in list(comb_1):
for jj in list(comb_2):
print ii, jj
I expected to see 9 printout results. But instead, whether or not I used list function, it only shows the first 3 of them, see below:
(1, 2) ('a', 'b')
(1, 2) ('a', 'c')
(1, 2) ('b', 'c')
I believe there is something to do with the combinations, as it is a generator to be used in iterations and can be used only once. Does that mean, it cannot be used in nested for loop? Why does it only print the first combination of comb_1 in the above example?