+ 5
list=[1,1,2,3,5,8,13] What will be output if next line of code is print (list[list[4]])??? and how???
13 Antworten
+ 51
It's easy but but tricky .... first of all it will access the element at Index 4 of the list. Inner list will be solved first
print (list [list [4]])
As you know list start with Index 0 so in the list 4th index value is 5
print(list [5])
now this will print element of index 5 which is 8
Answer is 8
+ 18
1. Look at what is the value of list[4]. We see it is 5.
2. Supstitude list[4] with its value. (5)
3. Now we have list[5] which is 8 :)
+ 8
Or you can test it in py console)) Like this:
>>> list=[1,1,2,3,5,8,13]
>>> list
[1, 1, 2, 3, 5, 8, 13]
>>> list[4]
5
>>> list[5]
8
>>> list[list[4]]
8
+ 3
I'm mathematical terms, it is f°f (f composed of f). All of the other comments explain the concept.
+ 1
Algorithm: Word used by programmers when they dont`t want to explain what they did.
https://www.python.org/doc/humor/
+ 1
8
+ 1
Hi can someone break down what the code is commanding?
I get the idea that the 4th element of the list is 5.
So the next part is where is struggle: how does it then move to become 8
I think i need to understand this part of the code (what the brackets are doing here?)
(list[list[4]])
I think i got it somewhat... so we are telling the code to look at the list 4th value which is 5. To then take this 5 and reuse it as the 5th index in the list to print .. seems awfully complicated.
0
well explained everyone👍
- 1
ans : 8
- 1
Answer is 8
- 1
8
- 1
What's the output of this code?
list = [1, 1, 2, 3, 5, 8, 13]
print(list[list[4]])
Answer is 8
- 4
The answer is 8 bruh