0

it's about list

list = [1,1,2,3,5,8,13] print(list[list[list[4]]) the result is 8, but I don't know why. thank You to explain.

24th Oct 2020, 3:37 PM
Brigitte Rabarijaona
Brigitte Rabarijaona - avatar
1 Resposta
+ 3
list[4] is 5 hence, list[list[4]] is list[5], which is 8 list[list[list[4]]] is list[8], which is undefined. Your code snippet is missing a closing ] and if the third closing ] exists, it will raise Index Out Of Range Error instead of printing 8
24th Oct 2020, 3:41 PM
Gordon
Gordon - avatar