Dictionaries | SoloLearn: Learn to code for FREE!

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

5/2/2020 12:24:12 PM

Colin

3 Answers

New Answer

+2

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:-)

0

Abhay i am reading it as, the index 3 * index 1 in sampleList2, is that right?

0

got it!!! its asking for the the index of thr index...since its nested, right?