What is the output of this code...?? Help me and explain too | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the output of this code...?? Help me and explain too

L = [[2,3,4],[5,6,7],[8,9,10]] Print(L[1][-1])

1st Mar 2021, 5:07 PM
Nagaraj K
Nagaraj K - avatar
1 Answer
+ 1
L = [[2,3,4],[5,6,7],[8,9,10]] print(L[1][-1]) L[1] refers to [5,6,7] and [-1] refering index from last (reverse way (...,-3,-2,-1) from last to first index 0 (instead of 0,1,2,3,...)) so L[1][-1] refers to 7 from [5,6,7]
1st Mar 2021, 5:43 PM
Jayakrishna 🇮🇳