0

I used a for loop to create many lines to draw a grid on code, and I want my lines to get clicked on and return a different color. My current code goes like this:

for i in range(100, w-100, 100):
         for n in range(100, 700, 100):
             a1 = mainCanvas.create_line(i, n, i + 100, n, tag='grid_line', width=4, activefill=player1Color,                    fill="black")
     for j in range(100, h-100, 100):
         for n in range(100, 700, 100):
             a2 = mainCanvas.create_line(n, j, n, j+100, tag='grid_line', width=4, activefill="red", fill="black")

I have created the lines, all i need now is individual coordinates to store them, and I cant figure out how to call them one by one as a variable.

Axe319
  • 4,255
  • 3
  • 15
  • 31
  • 1
    Does this answer your question? [How do I create variable variables?](https://stackoverflow.com/questions/1373164/how-do-i-create-variable-variables) – 0x5453 Dec 09 '21 at 19:04
  • 2
    standard rule: if you use `for`-loop then keep results on list. – furas Dec 09 '21 at 20:08

0 Answers0