0

How compiler understand 2nd list item in nested list

eg. nums[5,4,3,[2],6] here nums[3][0] is 2 in 2nd list how?

26th Sep 2016, 2:26 AM
Onkar Ashok Gumate
Onkar Ashok Gumate - avatar
3 Answers
+ 1
It's done in steps. First, nums[3] is acquired and a temporary reference to it (e.g., tempnums) is created. Then tempnums[0] is requested (it contains one item: 2), that value is returned and the temporary variable is released.
26th Sep 2016, 5:27 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
Its better if we separate it like this. First nums[3] is executed and it returns a list. Now i can use that list and retrieve it's elements. In this case we have only 1 element. so nums[3][0] will return the value. Don't think it as 2d list.
26th Sep 2016, 6:26 AM
Rana Sarkar
Rana Sarkar - avatar
0
means 2nd list at 3rd index in 1st list and in that 2nd list first item is 2 ,so nums[3][0] is 2 actually 2d list is 1d
26th Sep 2016, 2:29 AM
Onkar Ashok Gumate
Onkar Ashok Gumate - avatar