0
Python hep needed- understanding list indexing
help me understand why the answer to the following code is 8: list=[1,1,2,3,5,8,13] print(list[list[4]]) I have a basic understanding of indexing however I don't understand this code. Please help.
3 Antworten
+ 2
Indexing starts from 0.
print(list[list[4]])
will print the value in the list at index list[4]
list[4] = 5th element = 5.
list[list[4]] = list[5] = 6th element = 8.
+ 1
oh wow that made complete sense. Again completely new to this. thanks
+ 1
Anytime :-)