A couple questions: 1- what is j? 2- what does the rows[x][y] object look like? I assume it's a dict that has a "rowspan" key. Can rows[x][y]["rowspan"] sometimes be 0?
Perhaps you're looking for something like this: rowgroups = [] rowspan = 0 for i in range( len(rows) ): if rowspan <= 0: rowspan = rows[j][0]["rowspan"] if rowspan == 0: rowspan = 1 rowgroups.append(rows[ i : i + rowspan ]) rowspan -= 1 -sjbrown -- http://mail.python.org/mailman/listinfo/python-list