I have a 3D, binary array/list in python which stores a sequence. I would like to iterate though the array and print out the sequence. However, being new to python, I am struggleing to set the looping variable of the inner loop to a certain value.
for r in range(9, len(resources)-9):
for i in items:
for j in items:
print('assign[',i,'][',j,'][',r,'] ==', assign[(r, i)][j].SolutionValue())
if assign[(r, i)][j].SolutionValue() ==1:
i=j
print('set i=j: i = ', i)
j=0
print('set j=0: j = ', j)
print()
See a partial solution below:
assign[ 0 ][ 0 ][ 9 ] == 0.0
assign[ 0 ][ 1 ][ 9 ] == 0.0
assign[ 0 ][ 2 ][ 9 ] == 0.0
assign[ 0 ][ 3 ][ 9 ] == 0.0
assign[ 0 ][ 4 ][ 9 ] == 1.0
set i=j: i = 4
set j=0: j = 0
assign[ 4 ][ 5 ][ 9 ] == 0.0
assign[ 4 ][ 6 ][ 9 ] == 0.0
assign[ 1 ][ 0 ][ 9 ] == 1.0
Inside the if statement of my code, I would like to set the i=j and return to j=0. It seems as if this works for i but not for j. Another option would be to break the inner loop, but I think there is no referencing to certain loops in python.
Thank you in advance!