- 3
List=[1,1,2,3,5,8,13] print (list[list[4]])
Output 8 why??? Now position 4 is 5 but it display the 8
9 odpowiedzi
+ 5
Yogeshwari M .
If you want to print the 4 position
The correct sintax to use is
print(list[4])
When you do
print(list(list[4])
You are printing list in position
In the result of list[4].
That is position 5
+ 4
n = list[4]
What's the value of n?
What's the value of list[n]?
+ 4
print(list[4])
Output = 5
print(list[list[4]])
list[4] is equal to 5
So list[list[4]] is equal to list[5]
So we have print(list[5])
Output is 8
+ 2
Just look at your code carefully
Here's what it says
print(list[list[4]])
>> list[5] // 5 cames here the way that you told above
>> 8
Simply it asks for the value corresponding to the value at index 4
+ 2
Did you read everyone's explanations?
+ 1
I can do ya print(list[list[4]])
It cames 8 not 5
+ 1
Thankyou for ur explanation
0
This question from the quiz has been bugging me for some time, trying to understand why the output is 8. Thanks to Anya's explanation I get what the code has been telling me all along.
Talk about starring blind.
Thank you, Anya.
0
yh anya's explanation really helped clear the smoke in my mind..