0

List/ Index- Why is this answer 8 and not 5, I'm new please explain.

What is the output of this code? list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]])

24th Feb 2017, 10:04 AM
Jamal Bee
Jamal Bee - avatar
2 Réponses
+ 5
Evaluate from inside -> list[4] first and list[list[4]] next. list[4] = 5 meaning list[list[4]] = list[5] = 8.
24th Feb 2017, 11:59 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 1
list[list[4]] list[4] = 5 list[5] = 8
24th Feb 2017, 10:18 AM
ChaoticDawg
ChaoticDawg - avatar