+ 2
how the last one will become 3???
number = 3 things = ["string", 0, [1, 2, number], 4.56] print(things[1]) print(things[2]) print(things[2][2]) ans:-> the output is 0 [1,2, number] 3 my question is how the last one will become 3???
4 odpowiedzi
+ 4
I would like to try to explain in a bit more depth.
number is a variable with an assigned value = 3
things = a list with 4 items
The index of the items are:
0: 'string'
1: 0
2: [1, 2, number] =>(another list)
3: 4.56
The index of the inner list is:
0: 1
1: 2
2: number =>( value = 3)
Print(things[2][2]) is an index slice of things which calls the inner list, which is then index sliced again which results in number.
number = 3
+ 6
It's a 2D array. The first [2] makes [1,2,number], the second [2] goes inside, referring to number, which is 3.
+ 4
Thank you also
+ 1
Thanks alot 😍😍😍😍