0
Python Lists
In the course it said m = [ [1, 2, 3], [4, 5, 6] ] print(m[1][2]) Could someone explain why the output is 6 instead of 2 for me? Thanks a lot!
2 Answers
+ 4
array start from 0.
x 0 1 2 < index
0 1 2 3
1 4 5 6
^
index
+ 1
Shirley Qiu The given list is m=[[1,2,3],[4,5,6]] in the 0th index, we have [1,2,3] (which itself a list) and in the 1st index, we have [4,5,6] (which itself again a list) we need m[1][2]
See, m[1] here is [4,5,6] and in that 2nd indexed element (m[1][2]) which is 6 so the o/p is 6.
Hope you got it nowđ