+ 2

What is the output of this code? I do not understand how the output is 8

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

15th Apr 2019, 10:33 AM
Paul Louis
Paul Louis - avatar
3 RĂ©ponses
+ 8
list[4] ---> 5 so: list[5] ---> 8
15th Apr 2019, 11:23 AM
Janusz Bujak đŸ‡”đŸ‡±
Janusz Bujak đŸ‡”đŸ‡± - avatar
+ 6
The innermost set of brackets is checked first. That's: list[4]. The value there is 5, so list[list[4]] equals: list[5] And that's 8.
15th Apr 2019, 10:40 AM
HonFu
HonFu - avatar
+ 1
Thank you very much HonFu Makes sense now
15th Apr 2019, 10:50 AM
Paul Louis
Paul Louis - avatar