0

LIsts

Can someone please explain to me why the output of this code is not 5? list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]])

26th Apr 2020, 10:40 AM
‏Eneri Alufan
‏Eneri Alufan - avatar
2 Respuestas
+ 3
It's 8. The reason is Operator Precedence... First it takes list[4], which is = 5. Then it takes the outer list having 5 in brackets, so list[5] is 8... Hope it helps..✌️
26th Apr 2020, 10:53 AM
Varun Vaswani
Varun Vaswani - avatar
+ 3
List[4]=5 ,then list[5]=8 ,
26th Apr 2020, 10:47 AM
Abhay
Abhay - avatar