+ 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:).

2nd May 2019, 11:22 PM
tristach605
tristach605 - avatar
2 Respuestas
+ 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;
2nd May 2019, 11:42 PM
Solo
Solo - avatar
+ 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:).
4th May 2019, 10:47 PM
tristach605
tristach605 - avatar