0
list
list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]]) can any body explain this code to me I can not understand it thank you for answer
6 Réponses
+ 2
list[list[4]]
list[4] =5 then list[5] return 8
+ 9
Hi Nooshin
The concept is actually quite intuitive!
The number in the list with the index 4 is 5
list[4] returns 5
Then that number is used to go through the list again! The code will print out 8
Because
since
list[4] = 5
Then
list[ list[4] ] = list[5]
Which is equal to 8!
Hope this helps and have a great day ☕🍩!
+ 8
That's exactly what I just said Jayakrishna🇮🇳 😕
+ 3
list = [1, 1, 2, 3, 5, 8, 13]
Here, list was assigned values, the following given numbers, [1, 1, 2, 3, 5, 8, 13]
print is a function that allows to print statements so for instance, print(list[list[4]])
here, it basically says print the list and I believe 4 has something to do with where the number is.. I am a beginner, sorry.
+ 1
(i cant reply via DM)
Vachila64☕ arrage answers in thread by sorting by date. And see who answered first. OK.. Who?
Edit : so not to confuse others, remove that post about tagged me, I edit mine after it...
0
... sorry but you shouldn't answer if you don't know! :)