+ 1
List question?
list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]]) answer is "8" how ?????????
3 Antworten
+ 3
list=[1,1,2,3,5,8,13]
print(list[list[4]])
|
list[4]=5
|
print(list[5])=8
where list[4] is replace by 5 because list[4] is 5 that's why you got 8.
+ 3
Parveen Kumar
The inner part of the expression 'list[4]' results in 5.
Now you have the expression print(list[5]).
Then 'list[5]' results in 8.
Here you have print(8).
Array are zero-based meaning that the index of the first element is 0, rather than 1.