when reffering to 2d lists which is the correct way the rows/columns are ordered? I am having trouble following some of the q&a on this site and others ….I always imagined it as the second way I show but idk?
[[a ,b, c],[d, e, f], [g, h, i], [j, k, l]]
is for easy visualization this?:
- [a, b, c]
- [d, e, f]
- [g, h, i]
- [j, k, l]
(making it 4 rows x 3 columns)
or this:
- [a, d, g, j]
- [b, e, h, k]
- [c, f, i, l]
neither way is “wrong,” as there is no right or wrong answer. rows and columns don’t have meaning until displayed in a certain way. in memory, it’s all stored linearly.
syntactically, all that matters is that if your 2d array is called
array, thenarray[0]is a 1-dimensional array, andarray[0][0]is an item.however, it’s very unusual for it to be considered any way besides the first way, as in English we read left to right, top to bottom.