+ 1

Whats the use of number=3. It works without using it.

27th May 2019, 7:29 AM
Sagar Gyanchandani
Sagar Gyanchandani - avatar
4 ответов
+ 4
Sagar Gyanchandani Let me explain you the whole code. # initialization number=3 * initialization of list named as "things" things=["string",0,[1,2,number],4.56] * Now where you have typed number in the list . There it will take 3 things=["string",0,[1,2,3],4.56] Now output time : print(things[1]) #prints 2nd elements which has index 1 = 0 print(things[2]) #prints 3rd element which has index 2 = [1,2,3] print(things[2][2]) #prints the 3rd element of 3rd element = 3 I.e. 3rd element of [1,2,3] = 3 You can put 3 instead of number and then you do need to initialize the value of number. Thanks
27th May 2019, 8:00 AM
Prince PS[Not_Active]
Prince PS[Not_Active] - avatar
+ 3
You can think variable name as a key or a link to it's value. When number = 3 And things = ["string", 0, [1, 2, number], 4.56] number in the sublist of things. Searches the number's variable, which was 3. Thus when ever you use things, it is just: things = ["string", 0, [1, 2, 3]]
27th May 2019, 7:58 AM
Seb TheS
Seb TheS - avatar
+ 1
number = 3 things = ["string", 0, [1, 2, number], 4.56] print(things[1]) print(things[2]) print(things[2][2])
27th May 2019, 7:50 AM
Sagar Gyanchandani
Sagar Gyanchandani - avatar
0
Thanks bro..
28th May 2019, 8:56 AM
Sagar Gyanchandani
Sagar Gyanchandani - avatar