0

I'm not understanding it ....

number = 4 num=5 things = ["string", 0, [1, 2, number], [4.56,num],5] print(things[1]) print(things[2][2]) print(things[2]) print(things[3][2])

23rd Nov 2016, 10:23 PM
Zameer shaikh
Zameer shaikh - avatar
2 Respostas
+ 2
It prints: 0 4 [1, 2, 4] Error Python lists are indexed starting with 0, so things[1] is the second member of the list: 0. Here things[2] is the third element on the list so things[2][2] is the third member of the third member of the array: 'number' which is equal to 4. As above, things[2] is the third element of the list: [1, 2, 4]. Here things[3][2] is the third element of the fourth element of the list. The fourth element of the list only contains two elements, so this produces are error.
23rd Nov 2016, 11:20 PM
Arthur Busser
Arthur Busser - avatar
0
now I got it [3][2] will display the 3rd place num ,in the 3rd place num 2nd place num want to b displayed but I hv not written it . .......tq☺
23rd Nov 2016, 11:32 PM
Zameer shaikh
Zameer shaikh - avatar