0

Need help understanding (list[list[4]])

list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]]) Not sure how answer is 8? Can someone help me understand? Thank you

3rd Oct 2020, 5:12 AM
Jason DeNault
Jason DeNault - avatar
4 Antworten
+ 4
List[4] returns 5 So, list([list[4]]) means list[5] & list[5] returns 8 That's why it returns 8
3rd Oct 2020, 5:14 AM
Twaatii
Twaatii - avatar
+ 1
start on the innermost one and work out. list = [1,1,2,3,5,8,13] list[list[4]] # list[4] == 5 list[5] # list[5] == 8 # output 8
3rd Oct 2020, 5:16 AM
Slick
Slick - avatar
+ 1
Jason DeNault Welcome && Keep Learning Bruh 🙂🤟
3rd Oct 2020, 5:18 AM
Twaatii
Twaatii - avatar
0
Niirmaal twaatii Thank you now I understand.
3rd Oct 2020, 5:17 AM
Jason DeNault
Jason DeNault - avatar