This is my best attempt, utilizing recursion, and only uses the standard library and a visual. I try to not use custom libraries
def listlength(mylist, k=0, indent=''):
for l1 in mylist:
if isinstance(l1, list):
k = listlength(l1, k, indent+' ')
else:
print(indent+str(l1))
k+=1
return k
a = [[1,2,3],[3,5,[2,3]], [[3,2],[5,[4]]]]
listlength(a)
# 11
and for good measure
a = []
x = listlength(a)
print('length={}'.format(x))
# length=0
a = [1,2,3]
x = listlength(a)
print('length={}'.format(x))
#1
#2
#3
#length=3
a = [[1,2,3]]
x = listlength(a)
print('length={}'.format(x))
# 1
# 2
# 3
#length=3
a = [[1,2,3],[1,2,3]]
x = listlength(a)
print('length={}'.format(x))
# 1
# 2
# 3
# 1
# 2
# 3
#length=6
a = [1,2,3, [1,2,3],[1,2,3]]
x = listlength(a)
print('length={}'.format(x))
#1
#2
#3
# 1
# 2
# 3
# 1
# 2
# 3
#length=9
a = [1,2,3, [1,2,3,[1,2,3]]]
x = listlength(a)
print('length={}'.format(x))
#1
#2
#3
# 1
# 2
# 3
# 1
# 2
# 3
#length=9
a = [ [1,2,3], [1,[1,2],3] ]
x = listlength(a)
print('length={}'.format(x))
# 1
# 2
# 3
# 1
# 1
# 2
# 3
#length=7