- 1

Can anyone explain please?

list = [ 1,1,2,3,5,8,13 ] print (list[list[4]])

17th Jun 2021, 2:29 PM
SelvaKumar
3 Answers
+ 5
list[list[4]] list[5] # list[4] is 5 8 #index starts from 0
17th Jun 2021, 2:31 PM
TOLUENE
TOLUENE - avatar
+ 1
So i need to add 1 index. When list[list[index]] right....
17th Jun 2021, 2:56 PM
SelvaKumar
+ 1
SELVANITHISH SELVANITHISH No it is not like that. As index start from 0 so your 5th element will be at 4th index. So here list[4] = 5 #here 4 means 5th element and 5th element is 5 Now you have list[4] inside another list so here list[list[4]] = list[5] = 8 #here 5 is 6th element which is 8
17th Jun 2021, 5:41 PM
A͢J
A͢J - avatar