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

7th Oct 2020, 7:07 PM
Nooshin
6 Respostas
+ 2
list[list[4]] list[4] =5 then list[5] return 8
7th Oct 2020, 7:16 PM
Jayakrishna 🇮🇳
+ 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 ☕🍩!
7th Oct 2020, 7:18 PM
Vachila64☕
Vachila64☕ - avatar
+ 8
That's exactly what I just said Jayakrishna🇮🇳 😕
7th Oct 2020, 7:32 PM
Vachila64☕
Vachila64☕ - avatar
+ 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.
7th Oct 2020, 7:16 PM
...
... - avatar
+ 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...
7th Oct 2020, 8:16 PM
Jayakrishna 🇮🇳
0
... sorry but you shouldn't answer if you don't know! :)
7th Oct 2020, 7:30 PM
Abhay
Abhay - avatar