0

Dictionaries

Trying to understand results from a “dictionary.” sampleList = [1, 2, 3, 4] sampleList2 = [5, 6, 7, sampleList] print(sampleList2) print(sampleList2[3] print(sampleList2[3][1]. #explain how this works? [5, 6, 7, [1, 2, 3, 4] [1, 2, 3, 4] Why is the ANSWER 2? Thanks

2nd May 2020, 12:24 PM
Colin
3 ответов
+ 3
Sample list2 is [5,6,7,[1,2,3,4]] Sample list2[3] is [1,2,3,4] Sample list 2[3][1] is 2 ,try to read what's going on and you will understand:-)
2nd May 2020, 12:28 PM
Abhay
Abhay - avatar
0
Abhay i am reading it as, the index 3 * index 1 in sampleList2, is that right?
2nd May 2020, 4:57 PM
Colin
0
got it!!! its asking for the the index of thr index...since its nested, right?
3rd May 2020, 3:14 AM
Colin