+ 4
Can someoneone explain what is going on in the >>>print (things[2][2])? Why does it output 3?
number = 3 things = ["string", 0, [1, 2, number], 4.56] print(things[2][2])
12 Antworten
+ 7
number = 3. number in the array at index [2] [2] is number which value is assigned as 3. The array things= ["string",0,[1,2,number], 4.56] things = ["string", 0, [1,2,3], 4.56]
I hope this helps.
+ 6
print [2][2] the first [2] refers to:(1,2,number) the second [2] refers to number
+ 4
number is a variable which was assigned the value 3 at the beginning of the code. In list thing there's another list. The first number 2 refer to the position of the list nested in list thing. the second number 2 is the index of variable number which value is 3. Hope this will be helpful.
+ 2
In python when you write [ ][ ] it means you are getting into a list within a list.
In your case 1st [ ] represents list of things and 2nd [ ] represents list of [1,2,number].
Another things is that count of list is starts with 0 and then 1 and then 2 and so on.
So in things[2][2] means 1st [2] is position in list things which is [1,2,3] and 2nd [2] means 2nd position of this list which is 3.
+ 1
It's point 2 of the original list (which is a nested list) and then point 2 of the nested list. I think...
0
It means "print the second number of the second list"
0
Remember that arrays always starts counting from 0 :)
0
1) In things array, index[ 3 ]refers to [1,2,number]
2) In that array inner index [3] refers to number,which already assigned to 3.😀....so output =3.
0
NOT FIND THIS APP HELP FUL ANY RECOMMENDATION
0
@daniwl - try YouTube "learn Python"
- 1
I think it basically means the 3rd [2] item in the list within the list (which is again the third [2] in the outer list). Hope that makes sense.
- 1
can use plz explain that why print(things[1]) give error