I have been working with lists for a year now, but I am inconsistent with the way I have them setup. I want to know the standard. Let's say you have a computer represented as pixel colors in the form of a list. To simplify it let's just use numbers 1 through 9. Top left corner 1, top right corner 3, bottom left 7, bottom right 9, and the middle is 5. Which of the two ways below is the proper way to convert the screen into a list. The first way is visually appealing when you see it in the code, but accessing it this way is counterintuitive since I use [y][x] rather than [x][y]. The second way, the list in the code looks a little bit unfamiliar to what it actually represents, but it can be accessed intuitively by [x][y], and it is looped with x first. So which way is the standard or most common way of arranging lists in this situation?
a = [[1,2,3], [4,5,6], [7,8,9]]
Accessed by: a[y][x]
for y in range(len(a)): for x in range(len(a[y])): a[y][x]
a = [[1,4,7], [2,5,8], [3,6,9]]
Accessed by: a[x][y]
for x in range(len(a)): for y in range(len(a[y])): a[x][y]
Edited 5 Years Ago by Shane the House: n/a