+ 1

Can someone explain me the first question of the Module 2 Quiz ?

I don't understand the part with : print(list[list[4]]) Why is there list twice ?

13th Jul 2017, 9:59 AM
Adrien
Adrien - avatar
4 Respuestas
+ 2
See if this makes sense to you: list = [1, 2, 3, 4] print( list[1] ) # this equals to 2 So, list[ list[1] ] = list[2]
13th Jul 2017, 10:09 AM
Gustavo Saidler
Gustavo Saidler - avatar
+ 1
This example will help you: You have an array (named "list") with these elements. list[6]={1,2,3,4,5,0}. If you want to output list[list[4]] is the same like list[5]=0, because list[4]=5 (first index of array elements is 0). So just separate and calculate from inside...Hope you understood it...
13th Jul 2017, 10:05 AM
Ledio Deda
Ledio Deda - avatar
+ 1
Oh yes ! I understood ! Thank you so much ;)
13th Jul 2017, 10:08 AM
Adrien
Adrien - avatar
+ 1
I didn't understand the result one list was the call for the other. Now it's okay ! Thank you Ledio and Gustavo
13th Jul 2017, 10:14 AM
Adrien
Adrien - avatar