Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | NapalmNate |
I have this “simple” bit of code and I’m not sure why it isn’t working…
for i in Build_Location_Array:
if i.x == Build_Location_Start.x or i.y == Build_Location_Start.y:
print("x" + str(i.x) + " LocationStartX/" + str(Build_Location_Start.x) + " : y" + str(i.y) + " LocationStartY/" + str(Build_Location_Start.y))
Build_Location_Array.erase(i);
Token_Array.erase(i);
print(Build_Location_Array)
It’s just supposed to remove the first row of the x and y axis on a Vector2(4,4). But, for some reason that I haven’t figured out, it only removes five of the seven items that it’s supposed to remove in the array.
The debug:
x23 LocationStartX/23 : y1 LocationStartY/1
x23 LocationStartX/23 : y3 LocationStartY/1
x24 LocationStartX/23 : y1 LocationStartY/1
x25 LocationStartX/23 : y1 LocationStartY/1
x26 LocationStartX/23 : y1 LocationStartY/1
[(23, 2), (23, 4), (24, 2), (24, 3), (24, 4), (25, 2), (25, 3), (25, 4), (26, 2), (26, 3), (26, 4)]
if you notice in the array printout: (23,2) and (23,4) are still there although they should have been removed. (At least I think they should have.)
Does anyone see it? Cuz, I don’t see it!
Discovery:
After a bit more testing, I decided to just (copy/paste) run the same bit of code two more times. All variables stayed the same during the three runs of the above code.(except for "Build_Location_Array)
These were the results…(Still confused.):
x23 LocationStartX/23 : y1 LocationStartY/1
x23 LocationStartX/23 : y3 LocationStartY/1
x24 LocationStartX/23 : y1 LocationStartY/1
x25 LocationStartX/23 : y1 LocationStartY/1
x26 LocationStartX/23 : y1 LocationStartY/1
[(23, 2), (23, 4), (24, 2), (24, 3), (24, 4), (25, 2), (25, 3), (25, 4), (26, 2), (26, 3), (26, 4)]
x23 LocationStartX/23 : y2 LocationStartY/1
[(23, 4), (24, 2), (24, 3), (24, 4), (25, 2), (25, 3), (25, 4), (26, 2), (26, 3), (26, 4)]
x23 LocationStartX/23 : y4 LocationStartY/1
[(24, 2), (24, 3), (24, 4), (25, 2), (25, 3), (25, 4), (26, 2), (26, 3), (26, 4)]