# Python: Array of objects error

I am trying to make an array of columns and rows like this:

but when I run my code

I get

why is this?

Not sure this question is really suited here, but well…

 x = 0
y = 0
for row in range(rows):
x = x + scene.formationArrayColumnMargin
for ag in range(int(agentsPerRow)):
y = y + scene.formationArrayRowMargin


y must be reset to zero each time you run outer x loop, otherwise it keeps growing. Something like that:

x = 0
for row in range(rows):
y = 0
x = x + scene.formationArrayColumnMargin
for ag in range(int(agentsPerRow)):
y = y + scene.formationArrayRowMargin