+ 2
a = [[[[8, 9, 0]], 8]]
What is the output of this code? a = [[[[8, 9, 0]], 8]] print(len(a)) Output: 1 It's a list? But 8,9,0 is nested? So aren't there 2 items in the list? Thanks for any help:).
3 Answers
+ 3
a=[[...]]
b=[[[[[[...]]]]]]
len(a)==len(b)
a=[
[[[8,9,0]],8]
];
len(a)=1;
len(a[0])=2;
đ
1. a[0][0]=[[8,9,0]],
2. a[0][1]=8;
len(a[0][0])=1;
đ
1. a[0][0][0]=[8,9,0];
len(a[0][0][0])=3;
đ
1. a[0][0][0][0]=8;
2. a[0][0][0][1]=9;
3. a[0][0][0][2]=0;
+ 1
Thanks Bi, Vas and Jay.
Maybe it's symantics, but a list with three elements sounds like the length of the list should be 3?
Either way, I'll study more and thanks for your help:).