Python find list lengths in a sublist
list, python
Solution
`[len(x) for x in a[0]]` ?
>>> a = []
>>> a.append([])
>>> a[0].append([1,2,3,4,5])
>>> a[0].append([1,2,3,4])
>>> a[0].append([1,2,3])
>>> [len(x) for x in a[0]]
[5, 4, 3]
Problem
I am trying to find out how to get the length of every list that is held within a particular list. For example: ``` a = [] a.append([]) a[0].append([1,2,3,4,5]) a[0].append([1,2,3,4]) a[0].append([1,2,3]) ``` I'd like to run a command like: ``` len(a[0][:]) ``` which would output the answer I want which is a list of the lengths [5,4,3]. That command obviously does not work, and neither do a few others that I've tried. Please help!