Computer >> Computer tutorials >  >> Programming >> Python

How to get length of a list of lists in Python?


You can employ a nested loop to count number of elements in each sublist of a list

>>> a=[[1, 2, 3], [4, 5, 6]]
>>> c=0
>>> for x in a:
      for y in x:
      c=c+1


>>> c
6