+ 1
m = [ [1,2,3], [4,5,6] ] print(m[1][2])
In the code why output is 6?
2 ответов
+ 8
I would recommend you review indexing/slicing. This is a list of lists and since indexing starts at 0... m[1] is [4,5,6] and m[1][2] is the 3rd element, which is 6
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2431/?ref=app
https://realpython.com/lessons/indexing-and-slicing/
+ 3
m has two arrays...
Array one [1, 2, 3] which is 0
Array two [4, 5, 6] which is 1
So m[1] which is [4, 5, 6] of [2]
Which is 6