+ 1
Why not the output is 2?
a = [[[[8,9,0]],8]] print (len(a))
6 Answers
+ 4
Because Array length is 1
Explained here....
Consider first and last Square bracket, only one element is placed. Because you have used another square Bracket at 2nd last position.
+ 3
Because you are using an array inside another . So it gives length of outer array that is 1.
And a[0]=[[[8,9,0]],8]
+ 1
~ swim ~ i swear that you 24/7 in this app
+ 1
This is a 4 dimensional array.
[ [ [ [8, 9, 0] ], 8] ]
When you check length:
len([ [ [ [8, 9, 0] ], 8] ])
It only wants to know the length of the outermost list, it does not care what is in innermost lists, we can mark them with ..., because their content doesn't affect the list length:
[ [...] ]
[ [...] ] is a list with just 1 item: [...]
Thus len([ [ [ [8, 9, 0] ], 8] ]) returned 1.