+ 2

Can any help me? (Small doubt )

#why the answer is9 a=[4,3,9,5] b=a[-2] print(b)

29th Jun 2020, 9:53 PM
Bruklin
Bruklin - avatar
4 Answers
+ 7
indexing from last element goes like this -1,-2,-3,-4
29th Jun 2020, 9:57 PM
Abhay
Abhay - avatar
+ 2
Bruklin a[-2] means the second element list a from end of this array. a[-1]=5, a[-2]=9, a[-3]=3, a[-4]=4. So b=a[-2] means b=9...
29th Jun 2020, 10:00 PM
Petr
0
thank u everyone
13th Jul 2020, 2:06 AM
Bruklin
Bruklin - avatar