xstart = 0
ystart = 0
output = []
for y in range(0, ysize, intervaly):
    numberofrows = intervaly if y + intervaly * 2 < ysize else ysize - y
for x in range(0, xsize, intervalx):
    numberofcolumns = intervalx if x + intervalx * 2 < xsize else xsize - x
lst = [x, y, numberofcolumns, numberofrows]
output.append(lst)
Pythonic way to calculate offsets of an array