This problem has been getting at me for a while now. Is there an easier way to write nested for loops in python? For example if my code went something like this
for
This is fairly common when looping over multidimensional spaces. My solution is:
xy_grid = [(x, y) for x in range(3) for y in range(3)] for x, y in xy_grid: # do something for x1, y1 in xy_grid: # do something else