+ 2
Python 3 Tutorial, Modul 2 Quiz
Hi guys. I need your help. This is a task: "What is the output of this code? list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]])" I wrote it in text redactor and started... Well, the answer is 8. But I really dunno how this process work. Can anybody explain i details?
3 Answers
+ 6
print(list[list[4]])
list[4]=5
list[list[4]]=list[5]
print(list[list[4]])=print(list[5])=8
so finally the output is 8
it is executed from most inner to outer list so first list[4] value is find which is 5 then list[5] value is find which is 8 then it will print the value 8
+ 1
ok, now i got it
0
I think @GAWEN STEASY is right. You just have to start at the INNER list[4] =5 then the OUTER list[5] =8