I have a 2D Matrix named table and a list named count. In table the data is stored in count the numer of datasets in each column. first_index just show the number of the combination in this case there are 588 combinations (7*6*2*7) Now i want to create a any to any relation. My code is static so i need a possibility to create dynamic loops/Variables.
table:
[1, 30, 50, 60]
[2, 31, 51, 61]
[3, 32, 0, 62]
[4, 33, 0, 63]
[5, 34, 0, 64]
[6, 35, 0, 65]
[7, 0, 0, 66]
count:
[7, 6, 2, 7]
The Code works fine in my case but it is not sure if there are more than 4 rows so it is not really good code. I am a noob in python maybe there is another way to solve this problem
for k in range(count[0]):
for kk in range(count[1]):
for kkk in range(count[2]):
for kkkk in range(count[3]):
print('{0:3} , {1:3} , {2:1}'.format(first_index, table[k][0], 1))
print( '{0:3} , {1:3} , {2:1}'.format(first_index, table[kk][1], 2))
print( '{0:3} , {1:3} , {2:1}'.format(first_index, table[kkk][2], 3))
print( '{0:3} , {1:3} , {2:1}'.format(first_index, table[kkkk][3], 4))
print
first_index+=1
the output look like
1 , 1 , 1
1 , 30 , 2
1 , 50 , 3
1 , 60 , 4
2 , 1 , 1
2 , 30 , 2
2 , 50 , 3
2 , 61 , 4
...
588 , 7 , 1
588 , 35 , 2
588 , 51 , 3
588 , 66 , 4
first_index? You need to include a sample of output. What do you want your result to look like?