+ 1

m = [ [1,2,3], [4,5,6] ] print(m[1][2])

In the code why output is 6?

10th Sep 2020, 12:37 AM
Chahit Bhardwaj
Chahit Bhardwaj - avatar
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/
10th Sep 2020, 12:46 AM
Steven M
Steven M - avatar
+ 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
11th Sep 2020, 10:43 AM
KARTHIK
KARTHIK - avatar